[英]Open modal pop-up using custombox.js in Meteor
如何使用Meteor中的custombox.js插件打开模型弹出窗口? 它在我的非流星页面上运行良好,现在我似乎无法渲染它。
我认为问题在于custombox使用jquery的.fn原型,因为我收到未定义的函数错误。 我尝试了此操作,因为它应用于布局的子模板(feedsItem,而后者又是feed的子模板)。
该代码旨在打开一个模式弹出窗口,其中包含有关新闻发布的更多详细信息。 单击时应打开模式弹出窗口的超链接的html代码是:
<a href="#modal" class="list-group-item" id="flip">Read More</a>
和html作为模式弹出窗口打开(close onclick稍后也会成为事件。):
<div id="modal" style="display: none;" class="modal-example-content">
<div class="modal-example-header">
<button type="button" class="close" onclick="$.fn.custombox('close');">×</button>
<h4>Detalhe da Noticia</h4>
</div>
<div class="modal-example-body">
<p>Lorem Ipsum is simply dummy.</p>
</div>
</div>
我的模板事件代码是:
Template.feedsItem.events({
'click #flip': function(e){
var flip_position = ['vertical','horizontal'];
$.fn.custombox( this, {
effect: 'flip',
position: flip_position[Math.floor((Math.random()*2))]
});
e.preventDefault();
}
});
编辑我得到了显示的弹出窗口,但是当它打开时出现了404错误。 显然,这是因为它没有渲染目标div(模态)。 问题是我在子模板而不是父模板(Feeds)中渲染它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.