Skip to content

Instantly share code, notes, and snippets.

@abenevaut
Last active March 9, 2024 23:45
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 abenevaut/5851002 to your computer and use it in GitHub Desktop.
Save abenevaut/5851002 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function() {
	(function($) {
		
		// #1
		
		
		// Catch event
		$(document).bind('MY_EVENT', function()
		{
			// do something
		});
		
		
		// Fire event
		$(document).trigger('MY_EVENT');
		
		
		// !#1
		
		
		// #2
		
		
		$(document).on('MY_EVENT2', function(event, param1, param2) {
  			alert(param1 + "\n" + param2);
		});
		
		
		$(document).trigger('MY_EVENT2', ['param1_string', 'param2_string']);


		// !#2
			
		
	})(jQuery);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment