【发布时间】:2015-08-21 23:18:56
【问题描述】:
基本上我有两个相关的问题,但我会用数字将它们分开 1)我正在尝试将单个字段加载到集合中的选择下拉框中,但它填充了它从下面的列表中收集的所有重复值,而不是它自己的助手。
<template name="carsList">
{{> categoryFilter}}
<ul class="collection" id="listings">
{{#each cars}}
<li>
{{> carItem}}
</li>
{{/each}}
</ul>
</template>
类别模板是
<template name="categoryFilter">
<div class="input-field">
<select>
<option value="" disabled selected>Choose your option</option>
{{#each companyCategories}}
{{> companyCategory}}
{{/each}}
</select>
<label>Select Category</label>
</div>
</template>
<template name="companyCategory">
<option>{{ccategory}}</option>
</template>
categoryFilter 保存 iam 使用以下帮助程序的下拉模板
Template.categoryFilter.helpers({
companyCategories: function(){
return Cars.find();
}
});
而不是从它自己的助手中填充它加载来自它下面的“列表”的数据并重复数据。
Image of the result in selectbox
2)我还想根据选择下拉框中选择的值过滤列表(当然反应式)
请帮忙
编辑
这就是我的模板现在的样子
<template name="categoryFilter">
<div class="input-field">
<select>
<option value="" disabled selected>Choose your option</option>
{{#each companyCategories}}
{{> companyCategory}}
{{/each}}
</select>
<label>Select Category</label>
</div>
</template>
<template name="companyCategory">
<option>{{justCategory}}</option>
</template>
【问题讨论】:
标签: javascript meteor meteor-helper