Skip to content

Commit a100266

Browse files
committed
Fixed #1: "Select all" control didn't work when vertical scrolling is enabled
1 parent a58ad19 commit a100266

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

js/dataTables.checkboxes.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ Checkboxes.prototype = {
161161
// EVENT HANDLERS
162162
//
163163
var $table = $(dt.table().node());
164+
var $table_body = $(dt.table().body());
165+
var $table_header = $(dt.table().header());
164166

165167
// Handles checkbox click event
166-
$('tbody', $table).on('click', 'input[type="checkbox"]', function(e){
168+
$table_body.on('click', 'input[type="checkbox"]', function(e){
167169
self.onClick(e, this);
168170
});
169171

@@ -178,7 +180,7 @@ Checkboxes.prototype = {
178180

179181
// Otherwise, if Select extension is not available
180182
} else {
181-
$('tbody', $table).on('click', 'td', function(){
183+
$table_body.on('click', 'td', function(){
182184
var $row = $(this).closest('tr');
183185
var e = {
184186
type: ($row.hasClass('selected') ? 'deselect' : 'select')
@@ -197,12 +199,12 @@ Checkboxes.prototype = {
197199
});
198200

199201
// Handle click on "Select all" control
200-
$('thead', $table).on('click', 'th.checkboxes-select-all input[type="checkbox"]', function(e){
202+
$table_header.on('click', 'th.checkboxes-select-all input[type="checkbox"]', function(e){
201203
self.onClickSelectAll(e, this);
202204
});
203205

204206
// Handle click on heading containing "Select all" control
205-
$('thead', $table).on('click', 'th.checkboxes-select-all', function(e) {
207+
$table_header.on('click', 'th.checkboxes-select-all', function(e) {
206208
$('input[type="checkbox"]', this).trigger('click');
207209
});
208210
}
@@ -431,7 +433,7 @@ Checkboxes.prototype = {
431433
),
432434
search: 'applied'
433435
});
434-
436+
console.log(ctrl, dt, cells, cells.nodes());
435437
self.updateData('cell', cells.nodes(), ctrl.checked);
436438
self.updateCheckbox('cell', cells.nodes(), ctrl.checked);
437439

0 commit comments

Comments
 (0)