Reputation: 956
I am using currently DataTable, but I have this following error:
table.columns is not defined
$selector.html(data);
var table = $selector.find('table').DataTable({
"bLengthChange": false,
"order": [[ 0, "desc" ]],
initComplete: function() {
table.columns().every( function () {
var that = this;
$('input', this.footer()).on('keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
});
});
}
});
What is wrong with my code?
Upvotes: 1
Views: 1134
Reputation: 58880
Variable table
is not yet defined when initComplete
callback is called.
Change
initComplete: function() {
table.columns().every( function () {
to
initComplete: function(settings){
var api = new $.fn.dataTable.Api(settings);
api.columns().every( function () {
Upvotes: 3