Initialize JQuery Plugins AFTER fnDraw()

Initialize JQuery Plugins AFTER fnDraw()

swg1cor14swg1cor14 Posts: 2Questions: 0Answers: 0
edited March 2013 in DataTables 1.9
My server sends back the columns with one of these columns data having an icon that I have data-toggle="popover" and a title="some text". I use
[code]
"fnInitComplete": function() {
$('.attnIcon').tooltip();
$(".attnIcon[data-toggle=popover]")
.popover({ html: true, placement: 'right'});
}
[/code]
And it works. But I have a setInterval every 30 seconds to call a fnDraw() on the table with this command:
[code]
setInterval(function() {
oDataTable.fnDraw(false);
$('.attnIcon').tooltip();
$(".attnIcon[data-toggle=popover]")
.popover({ html: true, placement: 'right'});
} , 30000);
[/code]
oDataTable is my variable set for the table and it redraws the table correctly however the tooltop and popovers do not work. Its like:
[code]
$('.attnIcon').tooltip();
$(".attnIcon[data-toggle=popover]")
.popover({ html: true, placement: 'right'});
[/code]
Don't get called after the fnDraw(). So how can I reinitialize tooltop and popover after fnDraw().

Example: http://forexflowcopier.com/addUser.php

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Since you are using server-side processing, use fnDrawCallback rather than fnInitComplete so it happens on every draw.

    Thanks for the link to the test page :-)

    Allan
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Sounds about right! I have a whole mess of stuff like this... some only need to be called on InitComplete, some need to be called on fnDraw... some in fnRowCallback... I use $.when on pages with multiple datatables as sort of a "initComplete for ALL tables" rather than setting counters....

    And wherever possible (not possible in your example!) I use delegated listeners. So for example, instead of binding a click even with each fnRowCallback, I make a generic listener that listens from the table level and therefore only need to bind once... then the clicks are able to get the needed information (most are in the href attribute) and act on it. ;)

    Anyhow, not adding anything new here... just commiserating that it's tricky getting the timing set up for a polling application. Lots of juggling!
  • swg1cor14swg1cor14 Posts: 2Questions: 0Answers: 0
    Thank you so much!! That works.
This discussion has been closed.