检查分页中的所有复选框 [英] checking al checkboxes in pagination

查看:82
本文介绍了检查分页中的所有复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含用户列表和复选框,并且每个复选框之前都有一个SELECT ALL按钮.代码工作正常.但是问题在于,由于分页,只有当前页面中的复选框被选中,当我通过分页的NEXT和PREVIOUS链接导航到其他页面时,这些复选框保持未选中状态.我会发现与这些东西有关的任何东西,或者可能是我在搜索错误的东西.请帮忙.

I have a page that contains user list and checkboxes before each of them and there is a SELECT ALL button.The code works fine. But the problem is that due to pagination, only the checkboxes in the current page gets selected, when i navigate to other pages via the pagination NEXT and PREVIOUS links, the checkboxes remain unchecked. I cudnt find anything related to these or may be i was searching the wrong thing. Please help.

我正在使用以下代码:

$('#selectAll').click(function(e) {
e.preventDefault();
var checkbox = $(":checkbox");
checkbox.attr('checked', !checkbox.attr('checked'));
});

推荐答案

对不起,我发现正在使用datatables.js,并且选择所有复选框的正确方法是使用以下代码:

sorry, i figured out that datatables.js was being used and the correct way to select all checkboxes was using this piece of code:

$('#selectAll').click(function()({
  $('input', oTable.fnGetNodes()).each( function() {
    $('input', oTable.fnGetNodes()).attr('checked','checked');
  } );
});

它起作用了,现在即使移至其他分页页面,所有复选框也都被选中.

It worked and now all checkboxes are getting selected, even on moving to other paginated pages.

这篇关于检查分页中的所有复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆