Skip to content

Commit 1c6150a

Browse files
committed
Fix #64: Corrected handling of state saving event
1 parent e45062b commit 1c6150a

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

js/dataTables.checkboxes.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*! Checkboxes 1.2.10
1+
/*! Checkboxes 1.2.11-dev
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.2.10
9+
* @version 1.2.11-dev
1010
* @file dataTables.checkboxes.js
1111
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
1212
* @contact http://www.gyrocode.com/contacts
@@ -392,26 +392,16 @@
392392
}
393393
});
394394
}
395-
396-
// If state saving is enabled
397-
if(ctx.oFeatures.bStateSave){
398-
// Handle state saving event
399-
$table.on('stateSaveParams.dt.dtCheckboxes', function (e, settings, data){
400-
// Initialize array holding checkbox state for each column
401-
data.checkboxes = [];
402-
403-
// For every column where checkboxes are enabled
404-
$.each(self.s.columns, function(index, colIdx){
405-
// If checkbox state saving is enabled
406-
if(ctx.aoColumns[colIdx].checkboxes.stateSave){
407-
// Store data associated with this plug-in
408-
data.checkboxes[colIdx] = self.s.data[colIdx];
409-
}
410-
});
411-
});
412-
}
413395
});
414396

397+
// If state saving is enabled
398+
if(ctx.oFeatures.bStateSave){
399+
// Handle state saving event
400+
$table.on('stateSaveParams.dt.dtCheckboxes', function (e, settings, data) {
401+
self.onStateSave(e, settings, data);
402+
});
403+
}
404+
415405
// Handle table destroy event
416406
$table.one('destroy.dt.dtCheckboxes', function(){
417407
// Detach event handlers
@@ -680,6 +670,24 @@
680670
});
681671
},
682672

673+
// Handles state save event
674+
onStateSave: function (e, settings, data) {
675+
var self = this;
676+
var ctx = self.s.ctx;
677+
678+
// Initialize array holding checkbox state for each column
679+
data.checkboxes = [];
680+
681+
// For every column where checkboxes are enabled
682+
$.each(self.s.columns, function(index, colIdx){
683+
// If checkbox state saving is enabled
684+
if(ctx.aoColumns[colIdx].checkboxes.stateSave){
685+
// Store data associated with this plug-in
686+
data.checkboxes[colIdx] = self.s.data[colIdx];
687+
}
688+
});
689+
},
690+
683691
// Updates state of the "Select all" controls
684692
updateSelectAll: function(colIdx){
685693
var self = this;
@@ -1155,7 +1163,7 @@
11551163
* @name Checkboxes.version
11561164
* @static
11571165
*/
1158-
Checkboxes.version = '1.2.10';
1166+
Checkboxes.version = '1.2.11-dev';
11591167

11601168

11611169

0 commit comments

Comments
 (0)