jQuery load and Datatables fnDrawCallback

jQuery load and Datatables fnDrawCallback

GameCharmerGameCharmer Posts: 3Questions: 0Answers: 0
edited May 2011 in Bug reports
I have recently ran into a strange instance when using callbacks on a loaded datatables table.

I have a div on my main page that, based on a selection, will load another page containing a table set up like the table in this URL
http://datatables.net/examples/advanced_init/row_grouping.html

To make a long story short, I am doing the following.

[code]
HideContent();
$('#MyDiv').load('tablepage.php', {'t', '123'}, function(){ ShowContent(); });
[/code]
HideContent and ShowContent are small functions that hide one div, show another, and change the class of the nav bar.

When fnDrawCallback fires, it stops jQuery Load. My quick fix for this was to add ShowContent(); in the fnDrawCallback area, but it took me the better part of an hour messing around before I figured it out.

Is this a desired effect, or is this a limitation/bug of jQuery or DataTables?

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    There is nothing in DataTables that should stop $().load - perhaps jQuery doesn't allow two xhr's at a time with $().load? That assumes you are using an xhr for the draw...

    Allan
  • GameCharmerGameCharmer Posts: 3Questions: 0Answers: 0
    That could be a possibility, but I am pretty sure I am only issuing one call.

    Do you know of any debug info scripts that would work for tracking this down.
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Not really I'm afraid. Firebug would show cancelled XHRs though.

    Allan
  • GameCharmerGameCharmer Posts: 3Questions: 0Answers: 0
    edited May 2011
    Thank you Allan. I don't see any errors in Firebug. I solved the issue by not hiding/showing my divs.

    I changed
    [code]
    HideContent();
    $('#MyDiv').load('tablepage.php', {'t', '123'}, function(){ ShowContent(); });
    [/code]
    To
    [code]
    $('#MyDiv').html('LOADING');
    $('#MyDiv').load('tablepage.php', {'t', '123'});
    [/code]
    Works great!

    Anyway, keep up the awesome work with data tables. I can't wait for 1.8! :)
This discussion has been closed.