diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 3cf7f39b..7cbb4799 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -436,7 +436,7 @@ }, updatePageDisplay: function( c, completed ) { - if ( c.pager.initializing ) { return; } + if ( c.pager && c.pager.initializing ) { return; } var s, t, $out, options, indx, len, table = c.table, wo = c.widgetOptions, @@ -1165,25 +1165,32 @@ destroyPager: function( c, refreshing ) { var table = c.table, p = c.pager, - s = c.widgetOptions.pager_selectors, + s = c.widgetOptions.pager_selectors || {}, ctrls = [ s.first, s.prev, s.next, s.last, s.gotoPage, s.pageSize ].join( ',' ), namespace = c.namespace + 'pager'; - p.initialized = false; - c.$table.off( namespace ); - p.$container - // hide pager - .hide() - // unbind pager controls - .find( ctrls ) - .off( namespace ); - if ( refreshing ) { return; } - tsp.showAllRows( c ); - c.appender = null; // remove pager appender function - if ( ts.storage ) { - ts.storage( table, c.widgetOptions.pager_storageKey, '' ); + // check pager object in case two successive pager destroys are triggered + // e.g. "destroyPager" then "removeWidget" - see #1155 + if ( p ) { + p.initialized = false; + c.$table.off( namespace ); + p.$container + // hide pager + .hide() + // unbind pager controls + .find( ctrls ) + .off( namespace ); + if ( refreshing ) { return; } + c.appender = null; // remove pager appender function + tsp.showAllRows( c ); + if ( ts.storage ) { + ts.storage( table, c.widgetOptions.pager_storageKey, '' ); + } + p.$container = null; + p.$goto = null; + p.$size = null; + c.pager = null; + c.rowsCopy = null; } - delete table.config.pager; - delete table.config.rowsCopy; }, enablePager: function( c, triggered ) {