【发布时间】:2018-03-02 15:37:23
【问题描述】:
我的 Template.PageName.helper Meteor.callPromise() 中有两个 Bootstrap Modal,我想按特定顺序启动它们。顺序为:modal.hide('loadingPageAnimation'),后跟modal.show('c2bNotifications')。
默认情况下,modal.hide('loadingPageAnimation')在页面Router.route('/page')被modal.show('loadingPageAnimation')激活
这成功显示了modal.show(loadingPageAnimation),而(在我的助手中)我的Meteor.CallPromise() 正在等待结果:
../client/main
Meteor.callPromise('c2b').then(
function(results) {
//### When results comes through, Modal.hide('loadingPageAnimation')
Modal.hide('loadingPageAnimation');
//### then Modal.show('c2bNotifications' along with results message)
Modal.show('c2bNotifications', {msg: results};
}).catch( function(error) {
alert("Error!");
}
);
这里的问题是,当Meteor.callPromise('c2b')返回结果时,Modal.hide('newLoadingModal');被成功隐藏,但Modal.show('c2bNotifications', {msg: results});只显示有时有时不显示。我希望Modal.show('c2bNotifications', {msg: results}); 始终显示/工作保持一致。谁能解释为什么会发生这种情况,并可能提供更好的编码解决方案,从而强制显示Modal.show('c2bNotifications', {msg: results});?
在我的模板文件下方查找。
../client/main.html
<template name="c2bNotifications">
<div class="modal fade makeAnOffer">
<div class="modal-dialog modal-sm">
<div class="modal-content modal_MakeAnOffer">
<div class="modal-header">
<h4 class="modal-title">Notification </h4>
</div>
<div class="modal-body">
<div id = approvedMsg > {{msg}} </div>
</div>
<div class="modal-footer c2bNotifications">
<button type="button" class="btn btn-primary btn-lg" id="paymentNotificationClose" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</template>
期待您的帮助
【问题讨论】:
-
你应该使用
$("#modal").modal("show")' OR$("#modal").modal("hide")` -
你可以使用:$('#modal').modal({show:false});初始化模态框,然后使用 $('#modal').modal('toggle');显示/隐藏它
-
@PankajMakwana 我正在使用 Meteor 框架,所以 `Modal.show('c2bNotifications', {msg: results};` 中的
c2bNotifications实际上是它自己的模板,而不是id 元素。很抱歉,我的问题并不清楚 -
@VinhNT 我正在使用 Meteor 框架,所以 `Modal.show('c2bNotifications', {msg: results};` 中的
c2bNotifications实际上是它自己的模板,而不是id 元素。很抱歉,我的问题并不清楚 -
显示你的模板文件
标签: javascript jquery twitter-bootstrap meteor