Datatables with live click event function

偶尔善良 提交于 2019-12-25 02:15:07

问题


What I am attempting to do is when the user clicks on the View All Content Pages it goes OUT of pagination view so I want it to remove the pagination links which it removes the pages but not the First Preview Next Last links, however when a user clicks on View Paginated Records then it adds the First Preview Next Last links.

http://jsfiddle.net/xtremer360/hrfYA/7/


回答1:


If you want to show/hide the pagination controls according to what you are doing you just need to show/hide them:

$('.viewAll').live('click', function(e) {
    e.preventDefault();
    oTable.fnLengthChange(-1);
    $(this).removeClass('viewAll').addClass('paginateRecords');
    $(this).find('strong').html('View Paginated Records');
    $('.pagination').hide();
});

$('.paginateRecords').live('click', function(e) {
    e.preventDefault();
    oTable.fnLengthChange(10);
    $(this).removeClass('paginateRecords').addClass('viewAll');
    $(this).find('strong').html('View All Content Pages');    
    $('.pagination').show();    
});

fiddle: http://jsfiddle.net/nicolapeluchetti/hrfYA/9/



来源:https://stackoverflow.com/questions/6808446/datatables-with-live-click-event-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!