Skip to content

Commit cc8be98

Browse files
committed
Corrected issue with event handlers still attached after table is destroyed.
1 parent 6620c6b commit cc8be98

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

js/dataTables.alphabetSearch.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! AlphabetSearch for DataTables v1.2.5
1+
/*! AlphabetSearch for DataTables v1.2.6-dev
22
* 2014 SpryMedia Ltd - datatables.net/license
33
* Gyrocode LLC - MIT License
44
*/
@@ -7,7 +7,7 @@
77
* @summary AlphabetSearch
88
* @description Show an set of alphabet buttons alongside a table providing
99
* search input options
10-
* @version 1.2.5
10+
* @version 1.2.6-dev
1111
* @file dataTables.alphabetSearch.js
1212
* @author SpryMedia Ltd (www.sprymedia.co.uk)
1313
* @contact www.sprymedia.co.uk/contact
@@ -225,7 +225,7 @@ function draw ( table, alphabet, context )
225225
// when alphabet panel has been drawn
226226
// because we are performing two-step rendering
227227
// that could trigger search hanlder when not needed
228-
table.one('search', function (e, context) {
228+
table.one('search.dt.dtAlphabetSearch', function (e, context) {
229229
var api = new $.fn.dataTable.Api( context );
230230

231231
// Redraw alphabet panel
@@ -346,7 +346,8 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
346346
.css('opacity', 0);
347347
} );
348348

349-
table.on('draw', function (e, context) {
349+
// Handle table draw event
350+
table.on('draw.dt.dtAlphabetSearch', function (e, context) {
350351
var api = new $.fn.dataTable.Api( context );
351352

352353
// Total number of column nodes
@@ -377,6 +378,12 @@ $.fn.dataTable.AlphabetSearch = function ( context ) {
377378
}
378379
});
379380

381+
// Handle table destroy event
382+
table.on('destroy.dt.dtAlphabetSearch', function(e, context){
383+
var api = new $.fn.dataTable.Api( context );
384+
api.off('.dtAlphabetSearch');
385+
});
386+
380387
// API method to get the alphabet container node
381388
this.node = function () {
382389
return alphabet;

js/dataTables.alphabetSearch.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)