admin管理员组文章数量:1327092
Here is my template:
<template name="textGoesHere">
{{#if currentUser}}
<div id="boxdiv">
<textarea id="box">{{user.text}}</textarea>
</div>
{{/if}}
</template>
Here is my Meteor event:
'change #box': function (e) {
Meteor.call('click', $("#box").val());
}
For some reason, this event only gets fired after you click out of the text area after you've changed it's contents. But apparently, the event is suppose to be called when the text area is changed which is the functionality I'm looking for.
Here is my template:
<template name="textGoesHere">
{{#if currentUser}}
<div id="boxdiv">
<textarea id="box">{{user.text}}</textarea>
</div>
{{/if}}
</template>
Here is my Meteor event:
'change #box': function (e) {
Meteor.call('click', $("#box").val());
}
For some reason, this event only gets fired after you click out of the text area after you've changed it's contents. But apparently, the event is suppose to be called when the text area is changed which is the functionality I'm looking for.
Share Improve this question asked Dec 28, 2014 at 1:45 Tyler James LeonhardtTyler James Leonhardt 8841 gold badge10 silver badges24 bronze badges 3- 1 Um, that is how JavaScript's onchange works in general. The event does not fire until the user leaves the element. If you want something different, you will need to use keypress/input and timers. – epascarello Commented Dec 28, 2014 at 1:46
- Unfortunately, I'm looking to solve a case where a user would paste something into the text area. keypress, timers, and change events don't fire instantaneously after some one pastes. – Tyler James Leonhardt Commented Dec 28, 2014 at 3:02
- 1 So listen for input/paste event. – epascarello Commented Dec 28, 2014 at 3:21
2 Answers
Reset to default 5Try looking for the following events if you want to cover your bases for handling that kind of input: 'input change paste keyup mouseup'
A little more prehensive (for me) with this :
'change #box, paste #box, keyup #box, mouseup #box': function (e) {
Meteor.call('click', $("#box").val());
}
本文标签:
版权声明:本文标题:javascript - METEOR on change event only get's fired on a text area after you click out of the text area - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742208060a2433188.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论