问题描述
我正在使用 Twitter 引导模式对话框.当我单击引导模式对话框的提交按钮时,它会发送一个 AJAX 请求.我的问题是模态背景不会消失.模态对话框确实会正确消失,但会保留在屏幕上创建不透明度的模态背景"
I am using the Twitter bootstrap Modal dialog. When I click on the submit button of the bootstrap modal dialog, it sends an AJAX request. My problem is that the modal-backdrop doesn't disappear. The Modal dialog does disappear correctly, but instead "modal-backdrop in" that creates the opacity on the screen remain
我能做什么?
推荐答案
确保在执行 AJAX 请求时没有替换包含实际模态窗口的容器,因为 Bootstrap 将无法找到引用当你试图关闭它时.在您的 Ajax 完整处理程序中删除模式,然后替换数据.
Make sure you're not replacing the container containing the actual modal window when you're doing the AJAX request, because Bootstrap will not be able to find a reference to it when you try to close it. In your Ajax complete handler remove the modal and then replace the data.
如果这不起作用,您始终可以通过执行以下操作强制它消失:
If that doesn't work you can always force it to go away by doing the following:
$('#your-modal-id').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
这篇关于Twitter 引导模式背景不会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!