Delay Event Handler Function For A Specified Elapsed Time - frequentFireLimit.js

File Size: 3.21 KB
Views Total: 61
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Delay Event Handler Function For A Specified Elapsed Time - frequentFireLimit.js

A simple jQuery plugin to prevent accidental repeated events (e.g. ajax requests) run in the browser by delaying jQuery .on() call.

jQuery's event system makes it easy to write handler functions that run too soon and fire again before the glue is available. This jQuery plugin avoid this problem by delaying the expected event handler to wait until the given time has elapsed.

See Also:

How to use it:

1. Add the frequentFireLimit.js library after jQuery.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/frequentFireLimit.js"></script>

2. Specify the number of milliseconds to wait before triggering the event handler function.

// Before
$('#element').on(event, selector, function(e) {
  // event handler
});
// After
$('#element').frequentFireLimit(event, DELAY, selector, function(e) {
  // event handler
});

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