How to use jQuery "$.when" method?
- by Uder Moreira
I don't understand from jQuery documentation how "$.when" method works. I'm am new in jQuery, so sorry if my question is too simple.
I am trying to do something like this:
var tableProgress;
tableProgress = "<table id='table-progress'><tr><td></td></tr></table>"
$.when(
$("#send-one").html('done. ' + tableProgress)
).done( function() {
$('#table-progress').dataTable();
} );
It does not work, I think it's because .dataTable() pluggin can't find the table so I am trying to use jQuery $.when.
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 tryied:
$("#send-one").html('done. ' + tableProgress);
$('#table-progress').dataTable();
Could you please help me?