[英]Bootstrap collapse is not working with the each loop of Meteor.js
我正在以下模板中检索位置列表
<template name="explore">
<h2>Explore Places</h2>
<ul>
{{#each locations}}
<h4><a data-toggle="collapse" data-target="#info">{{name}}</a></h4>
<p id="info" class="collapse">{{{information}}}</p>
{{/each}}
</ul>
</template>
每当单击位置时,我都希望通过使用bootstrap折叠来显示其相应的隐藏信息。 但是单击列表中的任何链接始终会显示列表中第一项的信息。
解决了这个问题,我为每个可折叠标签都使用了相同的“ id”:
<template name="explore">
<h2>Explore Places</h2>
<ul>
{{#each locations}}
<h4><button class="btn btn-mini" data-toggle="collapse" data-target="#{{name}}">{{name}}</button></h4>
<li>
<p id="{{name}}" class="collapse">{{{information}}}</p>
</li>
{{/each}}
</ul>
</template>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.