[英]Bootstrap Modal not displaying on form submit
I'd like to display a simple Bootstrap Modal that says "Your message has been sent, thank you" after a form has been submitted. 在提交表单后,我想显示一个简单的Bootstrap Modal,上面写着“您的信息已经发送,谢谢”。 I am using http://formspree.io to handle the form.
我正在使用http://formspree.io来处理表单。 As per the instructions on formspree.io I've added the following HTML to the form:
按照formspree.io上的说明,我在表单中添加了以下HTML:
<input type="hidden" name="_next" value="//mysite.com/#openmodal" />
This is to redirect users to my modal after form submission. 提交表单后,这会将用户重定向到我的模式。 However, the modal is not displaying - the link is redirecting back to the top of my homepage.
但是,该模式未显示-链接被重定向回我的首页顶部。
Here is the HTML for the modal: 这是模式的HTML:
<div class="modal fade" id="openmodal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
How about adding a check to detect if the hash in the url exist, something like: 如何添加检查以检测url中的哈希是否存在,如:
$(document).ready(function () {
if (window.location.hash === "#openmodal") {
$("#openmodal").modal("show");
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.