码迷,mamicode.com
首页 > 其他好文 > 详细

Advanced initialisation

时间:2018-06-13 19:37:23      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:time()   als   date   can   you   span   amp   cts   gettime   

1、DOM / jQuery events

$(document).ready(function() {
    var table = $(‘#example‘).DataTable();
     
    $(‘#example tbody‘).on(‘click‘, ‘tr‘, function () {
        var data = table.row( this ).data();
        alert( ‘You clicked on ‘+data[0]+‘\‘s row‘ );
    } );
} );

 

2、DataTables events

DataTables fires a number of custom events which you can bind to in the standard jQuery fashion (although note that the namespace dt must be used), allowing your code to perform custom actions when these events occur.
All custom events fired by DataTables are fired with the namespace dt in order to prevent conflicts arising with other jQuery plug-ins which also fire events. The DataTables on() method can be used like the jQuery on() method, but will automatically append the dt namespace if required.
This example shows the use of the order, search and page events by adding a notification that the event fired to an element on the page to show that they have indeed fired.

$(document).ready(function() {
    var eventFired = function ( type ) {
        var n = $(‘#demo_info‘)[0];
        n.innerHTML += ‘<div>‘+type+‘ event - ‘+new Date().getTime()+‘</div>‘;
        n.scrollTop = n.scrollHeight;      
    }
 
    $(‘#example‘)
        .on( ‘order.dt‘,  function () { eventFired( ‘Order‘ ); } )
        .on( ‘search.dt‘, function () { eventFired( ‘Search‘ ); } )
        .on( ‘page.dt‘,   function () { eventFired( ‘Page‘ ); } )
        .DataTable();
} );

 

Advanced initialisation

标签:time()   als   date   can   you   span   amp   cts   gettime   

原文地址:https://www.cnblogs.com/cuteguru/p/9179349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!