在我看来,我有以下几行:
//this code is within a {{#each item in controller.content}} so id will not be unique
//so by giving it just an id like i have is not going to work
{{#each item in controller.content}}
<div class="pull-right" id="qnty-bulk">{{view Ember.TextField class="span1 qnty-bulk" id="qnty-bulk" valueBinding="item.qnty" type="number" min="1" max="9999999" disabled=true}}</div>
<button class="pull-right" {{ action "increase" }}>
Up
</button>
{{/each}}
在我的控制器中,我有动作
actions: {
increase: function() {
var inputField = $("#qnty-bulk"); //how can I access the Ember.TextField here for each of my items in the {{#each item in controller.content}}??
var inputValue = inputField.val();
inputValue = (inputValue != null && inputValue != '' ? (isNaN(inputValue) ? 0 : inputValue) : 0);
inputValue++;
console.log(inputField.val());
inputField.val(inputValue);
},
我想每次单击向上按钮时将文本字段的值增加 1,我该怎么做?我可以使用 jquery 吗?