plugin that is automatically called at init?

plugin that is automatically called at init?

max4evermax4ever Posts: 45Questions: 0Answers: 0
edited September 2012 in Plug-ins
Hello I have made a test plugin

[code]
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
{
....
}
[/code]

is it possible to make it execute after init, just by including it's sourcecode ?

without having to add to all my pages this
[code]
"fnInitComplete": function()
{
this.fnPagingInfo();
}
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes - have the plug-in listen for the 'init' event on the table, or bind to the aoInitComplete array through the _fnCallbackReg method. For example, this is how DataTables core does it:

    [code]
    _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
    [/code]

    Allan
  • max4evermax4ever Posts: 45Questions: 0Answers: 0
    But i don't have oSettings outside of [code]$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )[/code]
    and if i add the row inside [code]$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )[/code] then it doesn't get executed
  • max4evermax4ever Posts: 45Questions: 0Answers: 0
    thanks for the half answer... i managed nonetheless to find out how
    hopefully this will help others

    [code]
    $.fn.dataTable.models.oSettings['aoInitComplete'].push( {
    "fn": $.fn.dataTableExt.oApi.fnPagingInfo,
    "sName": 'whatever'
    } );
    [/code]
This discussion has been closed.