Skip to content

Commit 82f49bc

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

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

js/dataTables.checkboxes.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*! Checkboxes 1.0.1
1+
/*! Checkboxes 1.0.2
22
* Copyright (c) Gyrocode (www.gyrocode.com)
33
* License: MIT License
44
*/
55

66
/**
77
* @summary Checkboxes
88
* @description Checkboxes extension for jQuery DataTables
9-
* @version 1.0.1
9+
* @version 1.0.2
1010
* @file dataTables.checkboxes.js
1111
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
1212
* @contact http://www.gyrocode.com/contacts
@@ -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
}

0 commit comments

Comments
 (0)