Css 引导模式背景赢得';不要消失

Css 引导模式背景赢得';不要消失,css,ajax,twitter-bootstrap,Css,Ajax,Twitter Bootstrap,因此,我使用Bootstrapsmodal创建了这个登录页面。但是,在调用完成后,模式将按其应该的方式消失。除了黑色的背景。如何确保背景也消失 My_Menu.cshtml: <div id="menu"> <div class="modal fade" id="form_login" role="dialog" aria-labelledby="form_LoginLabel" aria-hidden="true"> <div class=

因此,我使用
Bootstrap
s
modal
创建了这个登录页面。但是,在调用完成后,
模式
将按其应该的方式消失。除了黑色的背景。如何确保背景也消失

My_Menu.cshtml:

<div id="menu">
    <div class="modal fade" id="form_login" role="dialog" aria-labelledby="form_LoginLabel" aria-hidden="true">
        <div class="modal-dialog reset">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Login</h4>
                </div>

                @using (Ajax.BeginForm("SignIn", "Account", new AjaxOptions() { UpdateTargetId = "menu", InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess="CloseModal()" }, new { @class = "form-inline", @role = "form" }))
                {
                    <div class="modal-body">
                        @if(ViewBag.Message != null)
                        {
                            <p class="alert alert-warning">@ViewBag.Message</p>
                        }

                        <div class="form-group">
                            <label class="sr-only" for="email">Email</label>
                            <input class="form-control" type="email" id="email" name="email" placeholder="Enter email" value="" required="required" />
                        </div>

                        <div class="form-group">
                            <label class="sr-only" for="password">Password</label>
                            <input class="form-control" type="password" id="password" name="password" placeholder="Enter password" value="" required="required" />
                        </div>

                        <span id="message-login-loading" class="alert hidden"></span>
                        <span id="message-login-error" class="alert alert-danger hidden"></span>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-success" id="login" ><span class="glyphicon glyphicon-user"></span> Sign in</button>
                        @Html.ActionLink("Register", "Register", "Account", null, new { @class = "btn btn-primary" })
                    </div>
                }
            </div>
        </div>
    </div>
</div>
根据答案,问题是我的
Ajax
调用更新了我的
div
,因此模式不可见。然而,背景是,它无法连接到模态,因此不能像通常那样消失

我最后使用了

$('.modal-backdrop').remove();
在一次成功的ajax调用中,这将删除页面上的所有背景


请去投票给Fre他的答案。^^

您也可以使用按钮上的data background=“false”属性。

这是我的作品。

$('.close')。单击()

$(document.body).removeClass(“模式打开”)

$(“模式背景”).remove()


请创建一个JSFIDLE。还有“背景”?你是说覆盖层/背景吗?您的服务器代码不相关。@im1dermike:我不认为服务器代码不相关。自从我打电话给服务器后问题就出现了。代码显示了表单应该如何更新。我不明白的是,为什么白色模态后面褪色的黑色背景不会随模态一起消失。我无法在JSFIDLE中重做这个问题。很抱歉,当我将模式代码按原样弹出到Bootply中,并在页面加载时弹出,然后将其关闭时,它会正常消失:。除非有办法复制错误,否则我不确定任何人能给你多少帮助。@MattD:你在右上角用“close”x关闭模态?这对我也适用。在ajax调用之后,问题就出现了。我认为问题在于aja所做的更新。我想知道的是,如果ajax调用成功,是否有办法强制后台消失您应该能够发送一条成功消息,以便通过JavaScript进行处理。如果成功,请在您的model上运行
.model('hide')
,这样会完全隐藏它。问题是,如果没有一种可行的方法来测试或再现问题,这里的任何人都不可能帮助您。警告:我发现,由于模式背景在显示时会删除滚动条,因此此解决方案不会将滚动条返回到窗口。换句话说,在页面刷新之前,您不会有滚动条。虽然上述答案有效,但此处和此处提供的答案更好。这会隐藏模式,但用户需要单击两次以在代码后打开模式。。。。如何解决这个问题
$('.modal-backdrop').remove();