java - Javascript on (before and after) every Ajax-call -


since i'm working tinymce (please don't go "primefaces has editor" or similar) need execute small piece of javascript before , after every ajax-call. i'd prefer not edit every ajax-call since there lot (and doing bad practice future maintenance).

what elegant solution execute javascript pre- , post- ajax-call on page?

note: i'm using custom composite tinymce-textarea. events object suffice. though keep in mind actual ajax-trigger might invoked totally different object (though nevertheless rerender composite).

use jsf.ajax.addonevent handler.

jsf.ajax.addonevent(function(data) {     switch(data.status) {         case "begin":             // invoked right before ajax request sent.             break;          case "complete":             // invoked right after ajax response returned.             break;          case "success":             // invoked right after successful processing of ajax response , update of html dom.             // in case you're interested in error handling, use jsf.ajax.addonerror handler.             break;     } }); 

just put in js file included <h:outputscript target="head"> in <h:body> of desired pages. ensure it's loaded after jsf's own jsf.js containing jsf namespace.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -