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
Add a ment  | 

2 Answers 2

Reset to default 5

Try 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());

}

本文标签: