PrimeFaces uses jQuery under covers to handle ajax requests. That way, you can simply plug in a generic $.ajaxComplete() handler. The source is available as a property of the 3rd argument of options :
$(document).ajaxComplete(function(event, xhr, options) { var $source = $("[id='" + options.source + "']"); if ($source.hasClass("myCommandButton")) {
Or, if you are using PrimeFaces 4.0 or later, connect to the pfAjaxComplete event for PrimeFaces:
$(document).on("pfAjaxComplete", function(event, xhr, options) { var $source = $("[id='" + options.source + "']"); if ($source.hasClass("myCommandButton")) {
Or, if you mix PrimeFaces with "plain" HTML / jQuery and would like to apply on both:
$(document).on("ajaxComplete pfAjaxComplete", function(event, xhr, options) { var $source = $("[id='" + options.source + "']"); if ($source.hasClass("myCommandButton")) {
Regardless of the method, $source is the jQuery object of the original HTML DOM element on which the ajax action was run, which in this particular example is <p:commandButton> . This gives you the opportunity to delegate it to an additionally desired handler, for example. learning an element class.
source share