I've a paginated table (primeface datatable), changing page, content is loaded via ajax. On complete event of the ajax request, data-ng-click attribute is added to all rows.
Here is how tr is rendered
<tr data-ng-click="init(1,2)" class="ui-widget-content ui-datatable-even ui-datatable-selectable ui-state-highlight" aria-selected="true" role="row" data-rk="1-2" data-ri="0" >
Here is how I add data-ng-click attribute to tr, and how to angular app and controller are defined:
angularizeDataTable();
function angularizeDataTable(){
$("[data-rk]").each(function(i, val){
idt = $(this).attr("data-rk").split("-")[0];
idv = $(this).attr("data-rk").split("-")[1];
$(this).attr("data-ng-click", "init("+idt+","+idv+")");
})
.promise().done(function(){
app = angular.module('myapp', []);
app.controller('MainController', function($scope, $http){
$scope.init = function(idt,idv){
alert(idt+","+idv);
};
});
});
}
angularizeDataTable function is executed on page load and every time i change page
<p:ajax event="page" oncomplete="angularizeDataTable()" />
But after page event fire, data-ng-click is ignored, why?