Last active
December 13, 2018 15:22
-
-
Save adamdehaven/95554569d39b86af23793c1bc3ac254f to your computer and use it in GitHub Desktop.
jQuery Paste Events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.pasteEvents = function( delay ) { | |
| if (delay == undefined) delay = 20; | |
| return $(this).each(function() { | |
| var $el = $(this); | |
| $el.on('paste', function() { | |
| $el.trigger('prepaste'); | |
| setTimeout(function() { $el.trigger('postpaste'); }, delay); | |
| }); | |
| }); | |
| }; | |
| $('#some-element').on('prepaste', function () { | |
| // do something | |
| }).on('postpaste', function () { | |
| // do something | |
| }).pasteEvents(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment