From c6e5ead4da200db657b22c7307317c576f56083f Mon Sep 17 00:00:00 2001 From: futpib Date: Thu, 30 Mar 2017 13:24:08 +0300 Subject: [PATCH] Namespace events and add proper destuction --- dataTables.rowsGroup.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dataTables.rowsGroup.js b/dataTables.rowsGroup.js index d8ad449..04c49c8 100644 --- a/dataTables.rowsGroup.js +++ b/dataTables.rowsGroup.js @@ -92,7 +92,7 @@ var RowsGroup = function ( dt, columnsForGrouping ) this.order = [] var self = this; - dt.on('order.dt', function ( e, settings) { + dt.on('order.dt.rowsGroup', function ( e, settings) { if (!self.orderOverrideNow) { self.orderOverrideNow = true; self._updateOrderAndDraw() @@ -101,35 +101,39 @@ var RowsGroup = function ( dt, columnsForGrouping ) } }) - dt.on('preDraw.dt', function ( e, settings) { + dt.on('preDraw.dt.rowsGroup', function ( e, settings) { if (self.mergeCellsNeeded) { self.mergeCellsNeeded = false; self._mergeCells() } }) - dt.on('column-visibility.dt', function ( e, settings) { + dt.on('column-visibility.dt.rowsGroup', function ( e, settings) { self.mergeCellsNeeded = true; }) - dt.on('search.dt', function ( e, settings) { + dt.on('search.dt.rowsGroup', function ( e, settings) { // This might to increase the time to redraw while searching on tables // with huge shown columns self.mergeCellsNeeded = true; }) - dt.on('page.dt', function ( e, settings) { + dt.on('page.dt.rowsGroup', function ( e, settings) { self.mergeCellsNeeded = true; }) - dt.on('length.dt', function ( e, settings) { + dt.on('length.dt.rowsGroup', function ( e, settings) { self.mergeCellsNeeded = true; }) - dt.on('xhr.dt', function ( e, settings) { + dt.on('xhr.dt.rowsGroup', function ( e, settings) { self.mergeCellsNeeded = true; }) + dt.on('destroy.dt.rowsGroup', function ( e ) { + dt.off('.rowsGroup'); + }) + this._updateOrderAndDraw(); /* Events sequence while Add row (also through Editor) @@ -271,7 +275,7 @@ $.fn.dataTable.RowsGroup = RowsGroup; $.fn.DataTable.RowsGroup = RowsGroup; // Automatic initialisation listener -$(document).on( 'init.dt', function ( e, settings ) { +$(document).on( 'init.dt.rowsGroup', function ( e, settings ) { if ( e.namespace !== 'dt' ) { return; }