Dynamically appended elements:
+'<div class="ckit-container__ft" data-ckit-footer>'
+'<form action="" class="ckit-composer-form">'
+'<div class="ckit-composer">'
+'<textarea data-ckit-composer-textarea placeholder="Add your reply" autocomplete="off" name="message" class="form-control ckit-composer__textarea"></textarea>'
+'</div>'
+'</form>'
+'</div>'
I'm unable to bind keypress event into the textarea above like this:
jQuery('[data-ckit-composer-textarea]').bind('keypress',function(){
alert('hi');//does not invoked
});
So i'm doing using inline onkeypress event and this does work:
<textarea data-ckit-composer-textarea placeholder="Add your reply" autocomplete="off" onkeypress="enterMe()" name="message".....><textarea>
enterMe() function which registers key press multiple times
function enterMe(){
jQuery('[data-ckit-composer-textarea]').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
alert('hi);//invokes many times
}
});
}
How do I make alert('hi) invoked only once per ENTER keypress? I'm nt holding on it continuously or pressed it twice fastly which would have caused it to run multiple times.. What else could be the reason for this and how to solve it, pllease?