I want to capture change happened in textarea (keyup, and also copy&past), for keyup option i use :
$("textarea").keyup(function(){
// ajax call here
});
i added this to capture pasting or cutting by mouse then trigger keyup event on the textarea:
$("textarea").on('input propertychange', function() {
$(this).trigger(keyup);
});
the problem here is if i press a key in my keyboard , i get 2 ajax calls because the second function capture also keyup event.
Is there a way to prevent $("textarea").on('input propertychange'...
from detecting a press key ?
Why not test this simplification? As I tested your code, without success on detecting keyup in 'input propertychange' event.
//$("textarea").keyup(function(){
//// ajax call here
//});
$("textarea").on('input propertychange', function() {
//$(this).trigger(keyup);
// do ajax call here
});
the latter ignores only some control keys, ie, key without corresponding character input.
after doing some research i found a solution here :
How to run a function once when binding to multiple events that all trigger in Javascript?
i think this is the best solution to prevent calling event twice in my situation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With