【问题标题】:Bootstrap modal not closing properly引导模式未正确关闭
【发布时间】:2018-07-18 13:54:13
【问题描述】:

我有一个按钮,当我单击它时,它应该关闭引导模式。如果我使用 data-dismiss="modal" 在按钮上,我的服务器端点击事件不会触发。当我改为使用ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success", "$('#myTreatmentModal').modal('hide');", true);

模态框消失了,我的服务器端代码触发了,但模态框放在正文上的深色背景没有被删除。

如果您对我应该做什么有任何建议,我一定会很感激。

【问题讨论】:

    标签: javascript c# asp.net bootstrap-modal


    【解决方案1】:

    也尝试隐藏背景,这是一个 Javascript 函数,它通过 id 隐藏模式,然后隐藏全局模式背景。

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

    从 aspx 调用它:

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

    【讨论】:

    • 非常感谢您的建议。它可以工作,但是当模式关闭时页面没有响应,我不确定为什么
    • 我想通了。我还必须从 body 标签中删除 modal-open 。非常感谢。
    【解决方案2】:

    使用 jQuery.noConflict();在模型隐藏之前可能是由于 jquery 冲突而发生的

    【讨论】:

    • 感谢您的建议,但不幸的是它似乎没有任何区别
    猜你喜欢
    • 2020-01-30
    • 2019-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多