Twitter bootstrap 按钮操作提交后,停留在引导模式屏幕上
我使用的是引导模式,里面有一个表单。我希望模式在表单提交后保持打开状态,但它会关闭。我已经检查了在按钮上添加一个弹出框,该按钮无法在模式关闭前强制显示消息 有没有办法让它一直开着?我想在提交后向用户显示确认信息。在以前的帖子中找不到任何答案 也许我必须在提交后在视图中呈现不同的模板? 这是表单帖子中的按钮定义:Twitter bootstrap 按钮操作提交后,停留在引导模式屏幕上,twitter-bootstrap,twitter-bootstrap-3,Twitter Bootstrap,Twitter Bootstrap 3,我使用的是引导模式,里面有一个表单。我希望模式在表单提交后保持打开状态,但它会关闭。我已经检查了在按钮上添加一个弹出框,该按钮无法在模式关闭前强制显示消息 有没有办法让它一直开着?我想在提交后向用户显示确认信息。在以前的帖子中找不到任何答案 也许我必须在提交后在视图中呈现不同的模板? 这是表单帖子中的按钮定义: <form action="" method="POST"> <button type="submit" class="btn btn-default">Add&
<form action="" method="POST">
<button type="submit" class="btn btn-default">Add</button>
我还尝试添加:onclick=$'{{p.id}'。模式{'background':'static'}
有什么想法吗?谢谢。扩展到发送ajax请求 加价
示例我将jquery submit与ajax一起使用,类似于为formmy表单提供一个id,而不是jquery'my-form'。提交函数{e.preventDefault;//ajax submit};我已经在我的html末尾添加了这个,但是不起作用。给我看看你的脚本。标记和JSO现在在这里,我让它像小提琴一样工作,但是它没有提交表单。。我没有让POST事件处理表单。谢谢
<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn btn-custom" data-toggle="modal">Open Form</a>
<!-- Modal -->
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">My Form</h4>
</div>
<div class="modal-body">
<form id="my-form">
<div class="form-group">
<label class="control-label col-md-4" for="first_name">First Name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-4" for="last_name">Last Name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name"/>
</div>
</div>
<button type="submit" id="submit-form" class="btn btn-default">Save</button>
</form>
</div><!-- End of Modal body -->
</div><!-- End of Modal content -->
</div><!-- End of Modal dialog -->
</div><!-- End of Modal -->
$(document).on('submit','#my-form',function(event){
event.preventDefault()
var formData = $(this).serialize();
console.log(formData);
$.ajax({
url: "", // some php
data: formData,
datatype: "json",
type: "POST",
success: function(data) {}
});
});