Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datatables: Uncaught TypeError: Cannot read property 'asSorting' of undefined

I'm am new in jQuery, so sorry if my question is too simple.

I am trying to do something like this:

$("#send-one").html('done. ');

var tableProgress= $("<table id='table-progress'><tr><td></td></tr></table>");

$("#send-one").empty().append(tableProgress);

tableProgress.dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": false,
    "bInfo": false,
    "bAutoWidth": false
});

All this occurs inside jQuery ui Dialog Box.

It does not work, I think it's because .dataTable() pluggin can't find the table so I am trying to use jQuery $.when.

The error is this

Uncaught TypeError: Cannot read property 'asSorting' of undefined

What I need is: use .datatable pluggin in a table that is inserted in $("#send-one").html('done. ' + tableProgress) but, using .datatable() directly may not be synchronous to the insertion.

I also tried:

$("#send-one").html('done. ' + tableProgress);
$('#table-progress').dataTable();
like image 924
Uder Moreira Avatar asked Jun 26 '13 13:06

Uder Moreira


1 Answers

This other stack overflow question had a much clearer answer, that it must have a <thead> and a <tbody> to work: Jquery datatable integration error?

Your's is missing both.

like image 190
David Hobs Avatar answered Nov 04 '22 04:11

David Hobs