event execution order prioritize - Free Download Change Event Execution Order In jQuery - Prioritize.js

Free Download Change Event Execution Order In jQuery – Prioritize.js

Posted on

This time I will share jQuery Plugin and tutorial about Change Event Execution Order In jQuery – Prioritize.js, hope it will help you in programming stack.

event execution order prioritize - Free Download Change Event Execution Order In jQuery - Prioritize.js
File Size: 8.14 KB
Views Total: 627
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A tiny yet useful jQuery plugin to extend the jQuery on() method that enables the user to prioritize jQuery events where multiple event handlers are attached to an element.

How to use it:

1. Install & Download the package.

1 # Yarn
2 $ yarn add jquery-prioritize
3  
4 # NPM
5 $ npm i jquery-prioritize --save

2. Load the main script after jQuery.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/lib/index.js"></script>

3. Attach multiple event handles to an element and set the priority by passing the priority options as the second parameter to the on() method as follows:

1 <button id="example">Click Me</button>
01 var $test = $("#example");
02  
03 $test.on('click', 5, function (){
04   alert('Priority 5');
05 });
06  
07 $test.on('click', 1, function (){
08   alert('Priority 1');
09 });
10  
11 $test.on('click', 3, function (){
12   alert('Priority 3');
13 });
14  
15 $test.on('click', 2, function (){
16   alert('Priority 2');
17 });
18  
19 $test.on('click', 4, function (){
20   alert('Priority 4');
21 });

This awesome jQuery plugin is developed by IonicaBizau. For more Advanced Usages, please check the demo page or visit the official website.