Trigger event on changing Textinput or Textarea value MeteorJS
I want to add the content of a textarea (or textarea) to a reactive variable and bind it to a view similar to AngularJS double-binding.
The listening problem keydown
is that the last character will not be included. If I use keyup
, there will be a delay. Is there a way to listen for a value change in a textbox and set a reactive variable right after it changes?
Template.body.events({
"keydown #textarea":function(){
input.set( $('#textarea').val());
}
});
+3
user1506145
source
to share
1 answer
You can use HTML5 event input
, which is probably better for what you need.
Template.body.events({
"input #textarea":function(){
input.set( $('#textarea').val());
}
});
+1
saimeunt
source
to share