Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From bind to on #1293

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions addons/pager/jquery.tablesorter.pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
if ($out.length) {
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
// rebind startRow/page inputs
$out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function(){
$out.find('.ts-startRow, .ts-page').off('change' + namespace).on('change' + namespace, function(){
var v = $(this).val(),
pg = $(this).hasClass('ts-startRow') ? Math.floor( v / sz ) + 1 : v;
c.$table.triggerHandler('pageSet' + namespace, [ pg ]);
Expand Down Expand Up @@ -385,7 +385,7 @@
pagerArrows( table, p );
if ( !p.removeRows ) {
hideRows(table, p);
$(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
$(table).on('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
hideRows(table, p);
});
}
Expand Down Expand Up @@ -532,9 +532,9 @@
if (c.showProcessing) {
ts.isProcessing(table, true); // show loading icon
}
$doc.bind('ajaxError' + namespace, function(e, xhr, settings, exception) {
$doc.on('ajaxError' + namespace, function(e, xhr, settings, exception) {
renderAjax(null, table, p, xhr, settings, exception);
$doc.unbind('ajaxError' + namespace);
$doc.off('ajaxError' + namespace);
});

counter = ++p.ajaxCounter;
Expand All @@ -547,7 +547,7 @@
return;
}
renderAjax(data, table, p, jqxhr);
$doc.unbind('ajaxError' + namespace);
$doc.off('ajaxError' + namespace);
if (typeof p.oldAjaxSuccess === 'function') {
p.oldAjaxSuccess(data);
}
Expand Down Expand Up @@ -860,9 +860,9 @@
.hide()
// unbind
.find( ctrls )
.unbind( namespace );
.off( namespace );
c.appender = null; // remove pager appender function
c.$table.unbind( namespace );
c.$table.off( namespace );
if (ts.storage) {
ts.storage(table, p.storageKey, '');
}
Expand Down Expand Up @@ -953,17 +953,17 @@
p.regexFiltered = new RegExp(wo.filter_filteredRow || 'filtered');

$t
// .unbind( namespace ) adding in jQuery 1.4.3 ( I think )
.unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
.bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
// .off( namespace ) adding in jQuery 1.4.3 ( I think )
.off( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
.on('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
// don't change page if filters are the same (pager updating, etc)
if (e.type === 'filterStart' && p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
p.page = p.pageReset; // fixes #456 & #565
}
})
// update pager after filter widget completes
.bind('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
.on('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
p.currentFilters = c.$table.data('lastSearch');
if (p.initialized || p.initializing) {
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
Expand All @@ -975,19 +975,19 @@
ts.applyWidget( table );
}
})
.bind('disablePager' + namespace, function(e){
.on('disablePager' + namespace, function(e){
e.stopPropagation();
showAllRows(table, p);
})
.bind('enablePager' + namespace, function(e){
.on('enablePager' + namespace, function(e){
e.stopPropagation();
enablePager(table, p, true);
})
.bind('destroyPager' + namespace, function(e){
.on('destroyPager' + namespace, function(e){
e.stopPropagation();
destroyPager(table, p);
})
.bind('updateComplete' + namespace, function(e, table, triggered){
.on('updateComplete' + namespace, function(e, table, triggered){
e.stopPropagation();
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
// don't recalculate total rows/pages if using ajax
Expand All @@ -1006,13 +1006,13 @@
changeHeight(table, p);
updatePageDisplay(table, p, true);
})
.bind('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e, size){
.on('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e, size){
e.stopPropagation();
setPageSize(table, parsePageSize( p, size, 'get' ), p);
hideRows(table, p);
updatePageDisplay(table, p, false);
})
.bind('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e, num){
.on('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e, num){
e.stopPropagation();
// force pager refresh
if (e.type === 'pagerUpdate') {
Expand All @@ -1023,7 +1023,7 @@
moveToPage(table, p, true);
updatePageDisplay(table, p, false);
})
.bind('pageAndSize' + namespace, function(e, page, size){
.on('pageAndSize' + namespace, function(e, page, size){
e.stopPropagation();
p.page = (parseInt(page, 10) || 1) - 1;
setPageSize(table, parsePageSize( p, size, 'get' ), p);
Expand All @@ -1040,8 +1040,8 @@
}
pager.find(ctrls.join(','))
.attr('tabindex', 0)
.unbind('click' + namespace)
.bind('click' + namespace, function(e){
.off('click' + namespace)
.on('click' + namespace, function(e){
e.stopPropagation();
var i, $t = $(this), l = ctrls.length;
if ( !$t.hasClass(p.cssDisabled) ) {
Expand All @@ -1058,8 +1058,8 @@
p.$goto = pager.find(p.cssGoto);
if ( p.$goto.length ) {
p.$goto
.unbind('change' + namespace)
.bind('change' + namespace, function(){
.off('change' + namespace)
.on('change' + namespace, function(){
p.page = $(this).val() - 1;
moveToPage(table, p, true);
updatePageDisplay(table, p, false);
Expand All @@ -1072,7 +1072,7 @@
if ( p.$size.length ) {
// setting an option as selected appears to cause issues with initial page size
p.$size.find('option').removeAttr('selected');
p.$size.unbind('change' + namespace).bind('change' + namespace, function() {
p.$size.off('change' + namespace).on('change' + namespace, function() {
if ( !$(this).hasClass(p.cssDisabled) ) {
var size = $(this).val();
p.$size.val( size ); // in case there are more than one pagers
Expand Down
50 changes: 25 additions & 25 deletions js/jquery.tablesorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@
// show processesing icon
if ( c.showProcessing ) {
$table
.unbind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace )
.bind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace, function( e ) {
.off( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace )
.on( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace, function( e ) {
clearTimeout( c.timerProcessing );
ts.isProcessing( table );
if ( e.type === 'sortBegin' ) {
Expand Down Expand Up @@ -353,73 +353,73 @@
.join( namespace + ' ' );
// apply easy methods that trigger bound events
$table
.unbind( events.replace( ts.regex.spaces, ' ' ) )
.bind( 'sortReset' + namespace, function( e, callback ) {
.off( events.replace( ts.regex.spaces, ' ' ) )
.on( 'sortReset' + namespace, function( e, callback ) {
e.stopPropagation();
// using this.config to ensure functions are getting a non-cached version of the config
ts.sortReset( this.config, callback );
})
.bind( 'updateAll' + namespace, function( e, resort, callback ) {
.on( 'updateAll' + namespace, function( e, resort, callback ) {
e.stopPropagation();
ts.updateAll( this.config, resort, callback );
})
.bind( 'update' + namespace + ' updateRows' + namespace, function( e, resort, callback ) {
.on( 'update' + namespace + ' updateRows' + namespace, function( e, resort, callback ) {
e.stopPropagation();
ts.update( this.config, resort, callback );
})
.bind( 'updateHeaders' + namespace, function( e, callback ) {
.on( 'updateHeaders' + namespace, function( e, callback ) {
e.stopPropagation();
ts.updateHeaders( this.config, callback );
})
.bind( 'updateCell' + namespace, function( e, cell, resort, callback ) {
.on( 'updateCell' + namespace, function( e, cell, resort, callback ) {
e.stopPropagation();
ts.updateCell( this.config, cell, resort, callback );
})
.bind( 'addRows' + namespace, function( e, $row, resort, callback ) {
.on( 'addRows' + namespace, function( e, $row, resort, callback ) {
e.stopPropagation();
ts.addRows( this.config, $row, resort, callback );
})
.bind( 'updateComplete' + namespace, function() {
.on( 'updateComplete' + namespace, function() {
this.isUpdating = false;
})
.bind( 'sorton' + namespace, function( e, list, callback, init ) {
.on( 'sorton' + namespace, function( e, list, callback, init ) {
e.stopPropagation();
ts.sortOn( this.config, list, callback, init );
})
.bind( 'appendCache' + namespace, function( e, callback, init ) {
.on( 'appendCache' + namespace, function( e, callback, init ) {
e.stopPropagation();
ts.appendCache( this.config, init );
if ( $.isFunction( callback ) ) {
callback( this );
}
})
// $tbodies variable is used by the tbody sorting widget
.bind( 'updateCache' + namespace, function( e, callback, $tbodies ) {
.on( 'updateCache' + namespace, function( e, callback, $tbodies ) {
e.stopPropagation();
ts.updateCache( this.config, callback, $tbodies );
})
.bind( 'applyWidgetId' + namespace, function( e, id ) {
.on( 'applyWidgetId' + namespace, function( e, id ) {
e.stopPropagation();
ts.applyWidgetId( this, id );
})
.bind( 'applyWidgets' + namespace, function( e, init ) {
.on( 'applyWidgets' + namespace, function( e, init ) {
e.stopPropagation();
// apply widgets
ts.applyWidget( this, init );
})
.bind( 'refreshWidgets' + namespace, function( e, all, dontapply ) {
.on( 'refreshWidgets' + namespace, function( e, all, dontapply ) {
e.stopPropagation();
ts.refreshWidgets( this, all, dontapply );
})
.bind( 'removeWidget' + namespace, function( e, name, refreshing ) {
.on( 'removeWidget' + namespace, function( e, name, refreshing ) {
e.stopPropagation();
ts.removeWidget( this, name, refreshing );
})
.bind( 'destroy' + namespace, function( e, removeClasses, callback ) {
.on( 'destroy' + namespace, function( e, removeClasses, callback ) {
e.stopPropagation();
ts.destroy( this, removeClasses, callback );
})
.bind( 'resetToLoadState' + namespace, function( e ) {
.on( 'resetToLoadState' + namespace, function( e ) {
e.stopPropagation();
// remove all widgets
ts.removeWidget( this, true, false );
Expand Down Expand Up @@ -454,8 +454,8 @@
// http://stackoverflow.com/questions/5312849/jquery-find-self;
.find( c.selectorSort )
.add( $headers.filter( c.selectorSort ) )
.unbind( tmp )
.bind( tmp, function( e, external ) {
.off( tmp )
.on( tmp, function( e, external ) {
var $cell, cell, temp,
$target = $( e.target ),
// wrap event type in spaces, so the match doesn't trigger on inner words
Expand Down Expand Up @@ -510,7 +510,7 @@
// cancel selection
$headers
.attr( 'unselectable', 'on' )
.bind( 'selectstart', false )
.on( 'selectstart', false )
.css({
'user-select' : 'none',
'MozUserSelect' : 'none' // not needed for jQuery 1.8+
Expand Down Expand Up @@ -2429,15 +2429,15 @@
}
// remove widget added rows, just in case
$h.find( 'tr' ).not( $r ).remove();
// disable tablesorter - not using .unbind( namespace ) because namespacing was
// disable tablesorter - not using .off( namespace ) because namespacing was
// added in jQuery v1.4.3 - see http://api.jquery.com/event.namespace/
events = 'sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton ' +
'appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave ' +
'keypress sortBegin sortEnd resetToLoadState '.split( ' ' )
.join( c.namespace + ' ' );
$t
.removeData( 'tablesorter' )
.unbind( events.replace( ts.regex.spaces, ' ' ) );
.off( events.replace( ts.regex.spaces, ' ' ) );
c.$headers
.add( $f )
.removeClass( [ ts.css.header, c.cssHeader, c.cssAsc, c.cssDesc, ts.css.sortAsc, ts.css.sortDesc, ts.css.sortNone ].join( ' ' ) )
Expand All @@ -2446,7 +2446,7 @@
.attr( 'aria-disabled', 'true' );
$r
.find( c.selectorSort )
.unbind( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
.off( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
ts.restoreHeaders( table );
$t.toggleClass( ts.css.table + ' ' + c.tableClass + ' tablesorter-' + c.theme, removeClasses === false );
// clear flag in case the plugin is initialized again
Expand Down
12 changes: 6 additions & 6 deletions js/widgets/widget-cssStickyHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
}

$win
.unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.bind('scroll resize '.split(' ').join(namespace), function() {
.off( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.on('scroll resize '.split(' ').join(namespace), function() {
// make sure "wo" is current otherwise changes to widgetOptions
// are not dynamic (like the add caption button in the demo)
wo = c.widgetOptions;
Expand Down Expand Up @@ -127,8 +127,8 @@

});
$table
.unbind( ('filterEnd' + namespace).replace(/\s+/g, ' ') )
.bind('filterEnd' + namespace, function() {
.off( ('filterEnd' + namespace).replace(/\s+/g, ' ') )
.on('filterEnd' + namespace, function() {
if (wo.cssStickyHeaders_filteredToTop) {
// scroll top of table into view
window.scrollTo(0, $table.position().top);
Expand All @@ -139,9 +139,9 @@
remove: function(table, c, wo, refreshing) {
if (refreshing) { return; }
var namespace = c.namespace + 'cssstickyheader ';
$(window).unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
$(window).off( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
c.$table
.unbind( ('filterEnd scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.off( ('filterEnd scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.add( c.$table.children('thead').children().children() )
.children('thead, caption').css({
'transform' : '',
Expand Down
Loading