Created
November 12, 2015 12:47
-
-
Save milosdjakonovic/60c0ec27d6902354c829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $(element).triggerOnce('muCustomEvent') instead | |
* of $(element).trigger('muCustomEvent') | |
* when goal is to neutralize multiple event triggering | |
*/ | |
$.fn.triggerOnce = function(eventName){ | |
if (! this.data( 'triggered-' + eventName ) ) { | |
this.trigger(eventName).data( 'triggered-' + eventName, true ); | |
} | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment