checkAllのクリック機能は機能しますが、uncheckAllのクリック機能は機能しません。チェックされているすべてのチェックボックスのチェックを外すのを妨げるものは誰にも見えます。すべてのチェックボックスのチェックを外す
$('#checkAll').click(function (e) {
e.preventDefault();
$('#dataTablePageList :checkbox').attr('checked','checked');
$(this).removeAttr('id').attr('id','uncheckAll');
$(this).find('strong').html('Uncheck All Checkboxes');
});
$('#uncheckAll').click(function (e) {
e.preventDefault();
$('#dataTablePageList :checkbox').removeAttr("checked");
$(this).removeAttr('id').attr('id','checkAll');
$(this).find('strong').html('Check All Checkboxes');
});
EDIT:
私はそれが何もしない何らかの理由がこれを試してみました。理由は分かりません。
$('#dataTablePageList').delegate('#checkAll', 'click', function(e) {
e.preventDefault();
$('#dataTablePageList :checkbox').attr('checked',true);
$(this).removeAttr('id').attr('id','uncheckAll');
$(this).find('strong').html('Uncheck All Checkboxes');
});
$('#dataTablePageList').delegate('#uncheckAll', 'click', function(e) {
e.preventDefault();
$('#dataTablePageList :checkbox').attr('checked',false);
$(this).removeAttr('id').attr('id','checkAll');
$(this).find('strong').html('Check All Checkboxes');
});
編集3:
$('#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 Records');
$('.pagination').show();
});
私の投稿を更新しました。 –
代理人を使ってアプローチを変更することを検討してください。醜いです。 –
あなたの回答は素晴らしいです。 –