0

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 ?

1 Answer 1

1

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.
    }
});
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks Balucs...is there evenName for Ajax is Load ?jQuery(selector).on("load", callbackFunction);
For example, yes. It's just the standard HTML DOM event name. You only need to keep in mind the load event isn't invoked on ajax responses. You rather want to modify whatever you're doing inside the existing onload function.
Just to clarify ,so this jQuery.on will not be called if iput the "load" event.
No because it's fired only once. You need addOnEvent() here. Or to use on() on whatever you're doing inside your current onload handler function. E.g. jQuery(document).ready(function() { jQuery(someSelector).click(someCallback); }); should then be jQuery(document).ready(function() { jQuery(someSelector).on("click", someCallback); }); .
You're talking about jsf.ajax.addOnEvent()? You need to ensure that it is fired after the auto-included JSF JavaScript. Put it in $(document).ready() or something.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.