Making sure that you can bind multiple toggles to a single element without problems. Thanks to 'Mr Speaker' for the original patch. Fixes #5274.

This commit is contained in:
Mr Speaker 2009-11-11 09:46:24 -05:00 committed by John Resig
parent 4b55e94d08
commit 5cb1163469
2 changed files with 20 additions and 3 deletions

View file

@ -693,13 +693,14 @@ jQuery.fn.extend({
return this.click( jQuery.event.proxy( fn, function( event ) {
// Figure out which function to execute
this.lastToggle = ( this.lastToggle || 0 ) % i;
var lastToggle = ( jQuery.data( this, 'lastToggle' + fn.guid ) || 0 ) % i;
jQuery.data( this, 'lastToggle' + fn.guid, lastToggle + 1 );
// Make sure that clicks stop
event.preventDefault();
// and execute the function
return args[ this.lastToggle++ ].apply( this, arguments ) || false;
return args[ lastToggle ].apply( this, arguments ) || false;
}));
},