【发布时间】:2016-09-13 21:39:52
【问题描述】:
我无法让 HTML 选择选项按照我认为在 Meteor 中的工作方式工作。
这是一个示例,说明它如何与名为 Country 的集合的按钮一起使用。
模板
{{#each get_countries}}
<button class="btn btnCountryTest">{{iso3}} - {{name}} </button><br />
{{/each}}
客户端事件处理程序
'click .btnCountryTest': function(event){
console.log('clicked .btnCountryTest this._id: ' + this._id);
}
产生正确的输出,例如。
clicked .btnCountryTest this._id: 39cd432c-66fa-48de-908b-93a874323e2e
现在,我希望能够在从 HTML 选择选项下拉列表中选择项目时触发其他页面活动。我知道我可以将 ID 放在选项值中,然后使用 Jquery 等......我认为它可以与 Meteor “一起工作”,但我不知道该怎么做。
这是我正在尝试的,但它不起作用。
模板
<select class="input-xlarge country" id="country" name="country">
{{#each get_countries}}
<option value="{{iso3}}">{{name}}</option>
{{/each}}
</select>
处理程序
'click #country': function (event) {
console.log('Template.users_insert.events click .country this._id: ' + this._id);
}
哪个产生
Template.users_insert.events click .country this._id: undefined
显然不是我所期望的。在我求助于 Jquery 表单处理之前有任何想法吗?
谢谢 史蒂夫
【问题讨论】:
标签: javascript meteor