How to execute a JS or jQuery function after an update, reload in JSF and PrimeFaces?

1

I need to execute this function after a button gives an update="@ form" on the page

<script type="text/javascript">
    function carregaCss(){
        $(".ui-icon-calendar").addClass("glyphicon glyphicon-calendar corPadrao");
        $(".ui-icon-seek-first").addClass("glyphicon glyphicon-backward corPadrao");
        $(".ui-datepicker-next span").addClass("glyphicon glyphicon-circle-arrow-right");
    }
</script>

It works in the header of the page, but when the ajax update is executed it does not work and the icons do not receive the classes they should receive.

    
asked by anonymous 22.08.2014 / 03:27

2 answers

1

For the solution to be generic, put a call to the function inside the form.

So, every time an update is performed on form , the function will be called again, regardless of the component that has updated the form .

When form is rendered again, the function will be called again

The idea is that it looks like:

<h:form>
 <script type="text/javascript">
  carregaCSS();
 </script>
...
    
22.08.2014 / 16:25
0

I do this:

<p:commandButton ... update="@form" oncomplete="carregarCss()" />

o oncomplete runs whenever the request made by the component runs successfully. It is equivalent to success of ajax.

    
22.08.2014 / 14:20