user684434
user684434

Reputation: 1165

Ajax response how to Reload JQuery(JavaScript)

Our application is JSF2 framework when we make Ajax Calls in certain scenarios we need to re-invoke the java-script(jQuery-for UI style) ,when the Ajax response returns back from server.

The javascripts are not getting called ,when the Ajax response come back..

Is there any way to enable this ?

Upvotes: 0

Views: 853

Answers (1)

BalusC
BalusC

Reputation: 1109570

Either use jQuery.delegate() or jQuery.on() (depending on jQuery version) instead to reapply the functions on every change in the HTML DOM tree, e.g.:

jQuery(selector).on(eventName, callbackFunction);

or let JSF re-invoke the JS functions by specifying an JSF ajax event handler by jsf.ajax.addOnEvent, e.g.:

jsf.ajax.addOnEvent(function(data) {
    if (data.status == "success") { // Can be 'begin', 'complete' and 'success'.
        // Re-invoke your JS functions here.
    }
});

Upvotes: 1

Related Questions