[英]Modal content override by data-remote in Twitter Bootstrap
I'm trying to show a remote content inside a modal
using Twitter Bootstrap with this code: 我正在尝试使用Twitter Bootstrap使用以下代码在modal
显示远程内容:
<ol class="breadcrumb text-right">
<li><a data-target="#modal" data-toggle="modal" data-remote="/app_dev.php/resetting/request" href="#">Forgot password?</a></li>
<li><a data-target="#modal" data-toggle="modal" data-remote="/app_dev.php/registro" href="#">Register</a></li>
</ol>
<div aria-hidden="true" aria-labelledby="modalLabel" role="dialog" tabindex="-1" id="modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 id="myModalLabel" class="modal-title">Alert</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
When I click on any link that trigger modal, like this image: 当我点击任何触发模态的链接时,如下图所示:
But then, when content is loaded, I lost the modal setup and the remote content replaces the complete modal layout, like this image: 但是,当加载内容时,我丢失了模态设置,远程内容取代了完整的模态布局,如下图所示:
What I'm doing wrong? 我做错了什么?
Look in code generated by remote call 查看远程调用生成的代码
I take a closer look to the modal after it loads and just the <div class="modal-header">...</div>
dissapear and I don't know the cause. 我在加载后仔细查看模态,只是<div class="modal-header">...</div>
dissapear,我不知道原因。 This is the code for the modal after it loads the remote content: 这是加载远程内容后模式的代码:
<div aria-hidden="false" aria-labelledby="modalLabel" role="dialog" tabindex="-1" id="modal" class="modal fade in" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<form id="fos_user_resetting_request" class="fos_user_resetting_request form_registro" method="POST" action="/app_dev.php/resetting/send-email">
<h2>Solicitar nueva contraseña</h2>
<div>
<label for="username">Nombre de usuario:</label>
<input type="text" required="required" name="username" id="username">
<input type="submit" value="Restablecer contraseña" id="reset_btn">
</div>
</form>
<script>
$(document).ready(function() {
$("#fos_user_resetting_request").submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
cache: false,
url: "/resetting/send-email",
data: $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
});
});
</script>
</div>
</div>
</div>
Any advice? 有什么建议?
by default it set the content on "modal-content" class. 默认情况下,它将内容设置为“modal-content”类。 you can use ajax call to set content on "model-body" class or you can return following code in your remote function, then it will automatically set your model box. 您可以使用ajax调用在“model-body”类上设置内容,或者您可以在远程函数中返回以下代码,然后它将自动设置您的模型框。
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 id="myModalLabel" class="modal-title">Alert</h4>
</div>
<div class="modal-body">
-- YOUR FORM ITEMS --
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.