jsfcufon

how to call Cufon.refresh after user click on <h:commandButton>


In my project i have a <h:datatabel> that contains details of polls that defined in the system. I will use pagination in my page, then create use a next command with the following code:

<h:commandLink value="&lt;" action="#{PollSearchControler.next}" >
    <f:ajax render="checkall"  />
</h:commandLink>  

my button work good and when i click in it my table refresh and load new data. but i have a problem with Cufon. I use Cufon in my project for use non standard font. when my date changed, i must call Cufon.refresh(). this function render new data and show my data with my font. now i have a question:
How can i say to <f:ajax> that call Cufon.refresh() after it load new data?
thanks.


Solution

  • You can use the onevent attribute to call a javascript function, this function will be called three times during the request lifetime: begin, complete, success. for example <f:ajax render="checkall" onevent="refreshCuffon"/> and the function will be

    function refreshCuffon(data) {
       if(data.status == "success") { 
           Cufon.refresh()
       }
    }