You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 2, 2025. It is now read-only.
Hi, I'm using jQuery DataTables with socket.io on AngularJS, and I'm pushing an item to the data binding list on a socket message and digesting afterwards. When it happened, the datatable recreated itself instead of just updating the data and not working properly. I'm also randomly get the error *Warning: Cannot reinitialise DataTable, and when I do, the datatable failed to display. (afterwards I get Loading... displayed in the table.)
AngularJS
var app = angular.module('App', ['ui.bootstrap','ngAnimate', 'datatables']);
app.factory('socket', function () {
var socket = io.connect('http://' + document.domain + ':' + location.port + '/t');
return socket;
});
app.controller('controller', function ($scope, socket, $timeout, DTOptionsBuilder, DTColumnBuilder) {
$scope.data=[];
$scope.headers = {'Name':'name','Title':'title'}
socket.on('data', function (d) {
d = angular.fromJson(d);
$scope.data.push(d);
$scope.$digest();
});
$scope.dtOptions = DTOptionsBuilder.newOptions().withPaginationType('full_numbers').withOption('bInfo', false);
$scope.dtColumns = [];
$scope.dtInstance = {};
for (key in $scope.headers) {
$scope.dtColumns.push(DTColumnBuilder.newColumn($scope.headers[key]).withTitle(key));
}
});
In socket.on i'm using $scope.$digest(); because if i won't I won't see updates in the table. it stays empty (only after I refresh the page I see the rows but still it doesn't update), I tried with $scope.dtInstance.rerender(); but the table stays empty.
The text was updated successfully, but these errors were encountered:
Seeing the the same issue when updating from websocket and running $scope.apply, as described by GiankOtarola commented on Mar 19, 2015 in issue #250 .
Hi, I'm using jQuery DataTables with socket.io on AngularJS, and I'm pushing an item to the data binding list on a socket message and digesting afterwards. When it happened, the datatable recreated itself instead of just updating the data and not working properly. I'm also randomly get the error
*Warning: Cannot reinitialise DataTable
, and when I do, the datatable failed to display. (afterwards I getLoading...
displayed in the table.)AngularJS
HTML
In
socket.on
i'm using$scope.$digest();
because if i won't I won't see updates in the table. it stays empty (only after I refresh the page I see the rows but still it doesn't update), I tried with$scope.dtInstance.rerender();
but the table stays empty.The text was updated successfully, but these errors were encountered: