我正在使用 Semantic-Ui。现在我的下拉菜单有问题。
Dropdown 使用来自 minimongo 的值动态填充。
当我在 myTemplate.rendered 中执行 $('.menu').dropdown() 时,它认为 Dropdown 是空的并且它不起作用但是当我将它放入 dropdowntListItems.rendered 时,它会被调用 N 次。N 是项目的 count()。
此解决方案有效。有没有更好的解决方案?
//myTemplate
<div class="menu">
{{#each dropdowntList}}
{{> dropdowntListItems}}
{{/each}}
</div>
<template name="dropdowntListItems">
<div class="item">{{item}}</div>
</template>
Template.myTemplate.dropdowntList = function (){
return Items().fetch();
};
Template.dropdowntListItems.rendered = function(){
$('.menu').dropdown(); //gets called N times
};