如何在Meteor中显示引导模式?
从http://meteorpedia.com/read/Modals我可以看到Meteor-way是使用模板逻辑来显示/隐藏模态.
我试过在我的模板中添加模态
<div class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
我有一个变量showModal,它确定是否应该显示模态.但我不知道如何以编程方式显示/隐藏模态.
解决方法:
在模态中添加id
<div id="myModal" class="modal fade">
并使用modal()打开模态
$('#myModal').modal('show');
关闭模态
$('#myModal').modal('hide');
如果你想以Meteor方式打开模态
在JS中
Session.set('showModal', true); // Show modal
Session.set('showModal', false); // Hide modal
在模板中
{{#if showModal}}
<div class="modal fade"> <!-- Use Display block to show the modal by default -->
...
{{/if}}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。