Jquery 希望在ASP.NET MVC应用程序中启动保存按钮模式弹出窗口
我有Jquery 希望在ASP.NET MVC应用程序中启动保存按钮模式弹出窗口,jquery,asp.net-mvc,twitter-bootstrap,Jquery,Asp.net Mvc,Twitter Bootstrap,我有编辑表单页面,如果用户进行了任何更改,则所有更改都会显示在模式弹出窗口中。为此,我使用了Jquery来激发Modal。在模式弹出窗口中,提交按钮未被触发。如果我把按钮放在页面上,它就可以正常工作。我不知道我哪里出错了。任何建议和指导都会对我有用 我的.cshtml代码: @model TestProject.Models.Test @using (Html.BeginForm()) { <div class="form-horizontal" > @
编辑
表单页面,如果用户进行了任何更改,则所有更改都会显示在模式
弹出窗口中。为此,我使用了Jquery
来激发Modal
。在模式
弹出窗口中,提交按钮
未被触发。如果我把按钮放在页面上,它就可以正常工作。我不知道我哪里出错了。任何建议和指导都会对我有用
我的.cshtml
代码:
@model TestProject.Models.Test
@using (Html.BeginForm())
{
<div class="form-horizontal" >
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.FName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FName, new { htmlAttributes = new { @class = "form-control",@id = "FName" } })
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="btnSubmit" data-toggle="modal" data-target="ListofChanges">Next</button>
</div>
</div>
}
MyModal
弹出更改:
<div id="ListofChanges" tabindex="-1" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">PhoneBook Details changed from</h4>
</div>
<div class="modal-body">
<p id="error"></p>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" />
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
&时代;
电话簿详细信息已从更改
接近
请指导我为什么点击后提交按钮未被激活。提前谢谢。如果您想提交原始表单,当用户单击模式对话框上的提交按钮时,您应该连接该按钮上的
单击事件,并以编程方式提交表单
为模式中的submit按钮提供一个Id
,您可以使用该Id连接click事件
<input type="submit" id="btn-submit" class="btn btn-primary" />
如果要提交原始表单,当用户单击模式对话框上的“提交”按钮时,应连接该按钮上的click
事件,并以编程方式提交表单
为模式中的submit按钮提供一个Id
,您可以使用该Id连接click事件
<input type="submit" id="btn-submit" class="btn btn-primary" />
还值得指出的是,btnSubmit不是一个提交按钮-您使用了type=“button”
。如果需要提交按钮,请将其更改为type=“submit”
。Bootstrap的模态函数也是异步的,因此您也需要防止表单提交。还值得指出的是,btnSubmit不是一个提交按钮-您使用了type=“button”
。如果需要提交按钮,请将其更改为type=“submit”
。Bootstrap的模态函数也是异步的,所以您也需要防止表单提交。非常感谢。你的解决方案对我有效。谢谢你抽出时间,非常感谢。你的解决方案对我有效。谢谢你抽出时间。
$(function () {
$("#btnSubmit").click(function (e) {
e.preventDefault();
//your existing code goes here to set the modal content
//$("#error").html("First Name changed from Sam" );
$('#ListofChanges').modal("show");
});
$("#btn-submit").click(function() {
alert("going to submit other form");
$("#btnSubmit").closest("form").submit();
});
});