call back outside of the function

call back outside of the function

naveenkumarpgnaveenkumarpg Posts: 1Questions: 0Answers: 0
edited August 2012 in General
Hi all

This is my problem :-

i want to trigger couple of lines of code after the
$("#sometable").dataTable( .......); has called

i dont have scope to change the code in the plugin either in Js files (the are external sources)
and the tables are not available at the load after selecting some options the table will get render

what i need is
1) i need a selector of the table (like #sometable at top, these selectors are generic i don't have common classes for the tables)
2) i need to call another function after this datatable() has triggered

what is the scope to find these things, is there any binding or call back are available outside of the initialization of data tables
Please help


Thanks in advance
Naveen

Replies

  • ThibThib Posts: 51Questions: 2Answers: 0
    Hi,

    As advanced examples suggest, you can initialize you DataTables like that :

    [code]var oTable = $("#sometable").dataTable( .......);[/code]

    So you still have a reference to your table you can use after initialization.

    Moreover, you may find custom events useful : http://datatables.net/release-datatables/examples/advanced_init/dt_events.html

    Regards,
    Thibault
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    As Thibault says, you'll probably want to listen for a custom event here - specifically the `init` event (full list here: http://datatables.net/docs/DataTables/1.9.3/#details_events ).

    For example, you could do:

    [code]
    $('#example').bind('init', function () {
    ...
    } );
    [/code]

    Then the function will be executed when the DataTable is fully initialised.

    Allan
This discussion has been closed.