我在模态弹出窗口中显示主题列表,在模态上,我有两个按钮,下一个和上一个。我想当我点击上一个按钮时,它显示前10个主题,当我点击下一个按钮它显示接下来的10个主题。我的模板代码是这个
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="topic_selector_label">Quiz Settings</h4>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-condensed table-hover " >
<tbody>
{{#each topics}}
<tr>
<td>
{{name}}
</td>
</tr>
{{/each}}
</tbody>
</table>
<button type="button" class="btn btn-default" id="previous_topics">Previous Topics</button>
<button type="button" class="btn btn-default pull-right" id="next_topics">Next Topics</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div>
我的js代码是
'click #next_topics':function(){
var LIMIT=2;
skip_topics=skip_topics+2;
var syllabus = Meteor.syllabi.findOne(Session.get("currentSyllabusId"));
topics= Meteor.topics.find({subject_id: syllabus.subject_id, level_id: syllabus.level_id},{skip:skip_topics,limit:1})
return Template.syllabus_design({topics:topics})
},
我想更改下一个和上一个按钮的主题列表
答案 0 :(得分:0)
如果我理解正确,您的问题是由于点击时模板没有刷新,
请参阅:https://github.com/meteor/meteor/issues/1172#issuecomment-19832727
尝试将skip_topics
变为Session
变量并在模板中打印该变量 - 与awatson1978使用他/她的form_changed
会话变量在github问题中建议的方式相同。
要深入了解代码中出现的问题,请参阅http://docs.meteor.com/#reactivity