如何扩展initComplete数据表?

时间:2017-01-03 07:32:14

标签: javascript jquery jquery-plugins datatables

$('#example').dataTable( {
  "initComplete": function(settings, json) {
      alert( 'DataTables has finished its initialisation.' );
  }
} );

如何像oLanguange一样扩展initComplete?

$.extend( true, $.fn.dataTable.defaults.oLanguage, {
 "sSearch": "<label>Record per page</label> _INPUT_ "
});

1 个答案:

答案 0 :(得分:1)

$(document).on( 'init.dt', function ( e, settings ) {
    var api = new $.fn.dataTable.Api( settings );

    if ( api.init().pageResize ||
         $.fn.dataTable.defaults.pageResize )
    {
        new PageResize( api );
   }
} );

参考:https://datatables.net/reference/api/init()