简体   繁体   English

Ajax表单提交后,引导模态未加载

[英]Bootstrap modal not loading after ajax form submit

Having a weird issue with MVC and Bootstrap Modals with remote content. 带有远程内容的MVC和Bootstrap模式存在怪异问题。

Im currently using Bootstrap v3.3.5 and MVC 5. 我目前正在使用Bootstrap v3.3.5和MVC 5。

The modals fire up fine and load in the remote content as expected when using the link on the partial view on the initial page load so i know the modals do work. 使用初始页面加载的部分视图上的链接时,模态可以很好地激发并按预期方式加载到远程内容中,因此我知道模态确实可以工作。

The edge case is that parts of my Razor View have Prtial Views with MVC Ajax Forms that when submitted replace original html with the re-rendered Partial View and once this has happened the BootStrap modals wont load the remote content when the link is clicked. 极端的情况是,我的Razor视图的某些部分具有带有MVC Ajax窗体的Prtial视图,这些视图在提交时用重新渲染的Partial View替换原始html,一旦发生这种情况,BootStrap模态将不会在单击链接时加载远程内容。 The modal renders (i see the black overlay) however no content is loaded. 模态渲染(我看到黑色叠加层),但是未加载任何内容。

If i look at the network traffic there is no GET request to load up the remote content for the modal. 如果我查看网络流量,则没有GET请求为模式加载远程内容。

My _Layout.cshtml contains this modal that i populate with remote content when needed: 我的_Layout.cshtml包含此模态,在需要时会填充远程内容:

<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog"><div class="modal-content">@*-- Content loaded with Ajax --*@</div></div>
</div>

and the link i have in the partial view that is rendered after the Ajax Form submit looks like this: 我在Ajax表单提交后呈现的局部视图中的链接如下所示:

<a href="@Url.RouteUrl("ModalUserUpdate_GET", new { id = Model.Id})" data-target="#modal" data-toggle="modal">
    <i class="fa fa-edit"></i> Edit
</a>

Is there a bug in the Bootstrap Javascript that is causing this issue or am i missing something? Bootstrap Javascript中是否存在导致此问题的错误,或者我丢失了某些东西?

Any help would be great. 任何帮助都会很棒。

@StephenMuecke helped me get the answer I needed. @StephenMuecke帮助我获得了所需的答案。 The issue was a plugin that was causing the issue when the Ajax form reloaded part of the screen. 问题是当Ajax表单重新加载屏幕的一部分时导致问题的插件。

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

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