在流星中选择了错误的选项值 javascript

Wrong option value selected in meteor javascript

我正在 Meteor 中构建一个应用程序,但我在 return输入下拉列表的值时遇到了问题。我有一个包含 2 行以上的页面,其中每行都有一个下拉列表。如果我从第二行的下拉列表中选择一个值,我的应用程序 returns 是第一个下拉列表中的值。如果我从第一行以外的任何下拉列表中选择一个值,也会出现同样的问题。它将 return 第一行下拉列表中的值。这是我的模板:

<td>
<select id="clientsSelect" name="clients">
    <option disabled selected> Select Client </option>
    {{#each users}}
        <option value="{{this._id}}">{{this.profile.companyName}}</option>
    {{/each}}
</select>
</td>

这是我的templates.js

Template.adminTemplates.events({
    "change #clientsSelect": function(event, template){
        var selectValue = template.$("#clientsSelect").val(); //grab value of dropdown list
        console.log(select val: ' + selectValue); //always returns value of the FIRST dropdown list
    }
});

您只需要使用 event.target.val() 获取值,以便该值来自被单击的同一元素。还有更多info in the docs.