Should it work with ng-repeat?
My table data is populated with ng-repeat and it doesn't work. If I hardcode the data rows, it will work. Not sure if this is a bug, just asking what the intention is.
The same problem with ng-repeat, i get a wrong $index after sorting event
I think this is a bug, because paging action before ng-repeat.
I use this tricks to fix it, but user will see a blink.
setTimeout(function() {$('#tblOrders').trigger('footable_redraw');}, 1000)
Thanks @xwendotnet that worked for me. If you set the timeout interval to 0 it still works and there is no blink.
I solved it with a directive:
JS:
.directive('fooRepeatDone', function() {
return function($scope, element) {
if ($scope.$last) { // all are rendered
$('.table').trigger('footable_redraw');
}
}
})
HTML:
<tr ng-repeat="post in posts" foo-repeat-done>
@xwendotnet +1!
@AcademyLime works perfect BUT it won't work on ajax, had to use xwedontnet solution (or at least in the script i'm working on)
@AcademyLime Your directive snippet is very nice! I have added translation support.
.directive('fooRepeatDone', function($interpolate) {
return function($scope, element) {
if ($scope.$last) { // all are rendered
$('.footable').trigger('footable_redraw');
$('.footable').footable().bind({
'footable_row_collapsed' : function(e) {
//Your code when a row is collapsed
// console.log("footable_row_collapsed");
},
'footable_row_expanded' : function(e) {
//Your code when a row is expanded
// console.log('footable_row_expanded');
angular.forEach(angular.element('.footable-row-detail-name'), function(value, key){
var a = angular.element(value);
var t = a[0].innerText;
if(t.indexOf('{{') > -1 ){
var exp = $interpolate(t);
var res = exp($scope);
a[0].innerText = res;
}
});
},
});
}
}
})