Reputation: 943
Is there a way to call a JS or jQuery function afterwards a PrimeFaces dataGrid has switched between pages and the data content has changed? I have to set a jQuery function for items that are shown on a data grid, since the items are shown page by page, i have to re-attach this jQuery function to the new items that are shown. Have tried the following with no success;
//way #1 - call ajax on complete/ on success after a page link has been clicked
$('.ui-paginator').click(function(e) {
alert("enter");
$.ajax({
success: function(data, textStatus, jqXHR) {
alert("success");
$('.certain-class').attachFunction();
},
complete: function(data, textStatus, jqXHR) {
alert("complete");
$('.certain-class').attachFunction();
}
});
//way #2 - after the content of the data grid has changed, call the function
$('.ui-datagrid-content').ajaxComplete(function() {
alert("changed outside");
$('.certain-class').attachFunction();
});
The result I'm getting is that the alerts are beeing called (so, the function is attached) but always before the content on the dataGrid is changed, I thought of using a timeout, but this is not the desired approach.
I'm using PF 5.0 .
Upvotes: 0
Views: 770
Reputation: 10048
You can use an ajax page event:
<p:dataGrid>
<p:ajax event="page" onstart="alert("ajax started");"
onsuccess="alert("ajax success");"
oncomplete="alert("ajax completed");" />
</p:dataGrid>
Upvotes: 3