Skip to content

Instantly share code, notes, and snippets.

@milosdjakonovic
Created November 12, 2015 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milosdjakonovic/60c0ec27d6902354c829 to your computer and use it in GitHub Desktop.
Save milosdjakonovic/60c0ec27d6902354c829 to your computer and use it in GitHub Desktop.
/**
* $(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