0
我正在爲我的應用程序中的jquery數據表寫一個selectall按鈕。但按鈕行爲不一致,雙擊按鈕實際上取消選擇數據表中的複選框。這裏是我點擊按鈕事件的代碼。 sampleTable是我的jQuery數據表。用於在數據表中選擇全部的Jquery按鈕行爲。
$("#button_select_all").click(function() {
$(allSamplesTable.fnGetFilteredNodes()).find(':checkbox').each(function() {
$this = $(this);
$this.attr('checked', 'checked');
for (var i = 0; i < _sampleTableExports.length; i++) {
if (_sampleTableExports[i]["Id"] == $(this).val()) {
_sampleTableExports.splice(i, 1);
return true;
}
}
_sampleTableExports.push({ "Name": $(this).attr("name"), "Id": $(this).val() });
});
});
請注意,爲什麼按鈕在第二次點擊時未勾選複選框。
是'button_select_all'元素的一個按鈕還是一個複選框? – dcodesmith
我把它作爲一個外部按鈕。 – user2501873