Skip to content

Plugin for moving event handler to the beginning of the event queue so that this handler will be executed first, regardless of how many other handlers you had already attached.

License

Notifications You must be signed in to change notification settings

private-face/jquery.bind-first

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery.bind-first

bind-first is a tiny jQuery plugin for moving event handler to the beginning of the event queue so that this handler will be executed first, regardless of how many other handlers you had already attached.

Using jQuery.bind-first you may be sure that your event handler will be executed first, regardless of its actual appearance in the code.

Usage

$(/* selector */).onFirst(/* arguments  */);	// (only jQuery >= 1.7)
$(/* selector */).bindFirst(/* arguments  */);
$(/* selector */).delegateFirst(/* arguments  */);
$(/* selector */).liveFirst(/* arguments  */);
$(/* selector */).oneFirst(/* arguments  */);

The arguments are completely identical to the corresponding jQuery functions: bind, delegate, live, one and on.

Example

$('#bind a')
	// regular bind: binded first, will be runned second
	.bind('click', function() {
		alert('regular bind');
		return false;
	})
	// bindFirst: binded second, will be runned first
	.bindFirst('click', function() {
		alert('bindFirst');
		return false;
	});

License

MIT License

Copyright (c) 2014 Vladimir Zhuravlev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Plugin for moving event handler to the beginning of the event queue so that this handler will be executed first, regardless of how many other handlers you had already attached.

Resources

License

Stars

Watchers

Forks

Packages

No packages published