欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

多個(gè)datatable共存造成多個(gè)表格的checkbox都被選中

 更新時(shí)間:2013年07月11日 16:57:10   作者:  
所以當(dāng)有多個(gè)datatable 引用到一個(gè)頁(yè)面中的時(shí)候,全選事件會(huì)匹配全部的datatable,所以造成全部多個(gè)表格的checkbox被都被選中
【問(wèn)題原因】
這個(gè)應(yīng)該是 jquery.datatable 控件本身的一個(gè)缺陷。
該控件中的checkbox小插件的id是寫死的,所以當(dāng)有多個(gè)datatable引用到一個(gè)頁(yè)面中的時(shí)候,全選事件會(huì)匹配全部的datatable,所以造成全部多個(gè)表格的checkbox被都被選中。

【解決方法】
所以最好是修改jquery.datatable控件,給生成的每個(gè)datatable下的checkbox賦 予不同的id,因?yàn)閐atatable的id是不一樣的,所以可以把 datatable的id作為 checkbox的前綴組成一個(gè)唯一的id 。 具體這個(gè)checkbox的調(diào)用事件也需要同步 替換成這個(gè)新id,進(jìn)行事件的調(diào)用。
[修改文件]
jqurey.datatable.ext.js (v0.0.1)

1. init方法修改:
復(fù)制代碼 代碼如下:

$("#"+options.select_table).find('thead tr th:first-child')
.prepend('<input type="checkbox" value="CHK_ALL" id=“chk_all" />');
==>
$("#"+options.select_table).find('thead tr th:first-child')
.prepend('<input type="checkbox" value="CHK_ALL" id="'+options.select_table+'_chk_all" />');

2.subscribeAllChk方法修改:
復(fù)制代碼 代碼如下:

$("#chk_all").click(function(){
==>
$("#"+$.fn.datatable_ext.defaults.select_table+"_chk_all").click(function(){

3.subscribeChk方法修改:
復(fù)制代碼 代碼如下:

if(checked_chk_num == curr_page_chk_num){
$("#chk_all").attr('checked', 'checked');
}else{
$("#chk_all").removeAttr('checked');
}
==>
if(checked_chk_num == curr_page_chk_num){
$("#"+$.fn.datatable_ext.defaults.select_table+"_chk_all").attr('checked', 'checked');
}else{
$("#"+$.fn.datatable_ext.defaults.select_table+"_chk_all").removeAttr('checked');
}

相關(guān)文章

最新評(píng)論