简体   繁体   English

引导程序模式无法正常关闭

[英]Bootstrap modal not closing properly

I have a button that when I click it, it is supposed to close a bootstrap modal. 我有一个按钮,当我单击它时,它应该关闭引导程序模态。 if I use data-dismiss="modal" on the button my server side click event does not fire. 如果我在按钮上使用data-dismiss="modal" ,则不会触发服务器端click事件。 when I instead use ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "$('#myTreatmentModal').modal('hide');", true); 当我改用ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "$('#myTreatmentModal').modal('hide');", true);

The modal goes away and my server side code fires but the darkened background put on the body by the modal does not get removed. 模态消失了,我的服务器端代码触发了,但是模态赋予主体的深色背景并没有被删除。

If you have any suggestions as to what I should do I'd definitely appreciate it. 如果您对我应该做什么有任何建议,我将不胜感激。

Try hiding the backdrop too, this a Javascript function that hides the modal by its id and then hides the global modal backdrop. 也尝试隐藏背景,这是一个Javascript函数,通过其ID隐藏模式,然后隐藏全局模式背景。

function hideModal(id) {
  $("#" + id).modal("hide");
  $(".modal-backdrop").hide();
}

Call it from the aspx: 从aspx调用它:

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "hideModal('myTreatmentModal');", true);

use jQuery.noConflict(); 使用jQuery.noConflict(); before model hide may be this happened due to jquery conflict 由于jquery冲突,可能会发生模型隐藏之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM