模态弹出关闭按钮在MVC项目中不起作用 [英] Modal popup close button is not working in MVC project
本文介绍了模态弹出关闭按钮在MVC项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用模式弹出窗口,其中
I want to use modal popup where my
close
按钮不起作用。这些是以下问题。
我想使用
button is not working. These are the following concerns.
I want to use
<button type="submit" id="submit">Produce</button>
在
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
内保存数据想要在这个
Produce
按钮点击时填充模态弹出窗口。
因为我能够获得模态弹出窗口但是我无法
button click.
As I am able to get the modal popup but I am not able to
close
模态。如果我将按钮类型更改为按钮,则关闭按钮可以正常工作。但我希望输入
the modal. If I change the button type to button then close button works. But I want type to
Submit
。
我尝试了以下代码但到目前为止没有运气。我挣扎了2天。任何人有任何想法然后请分享。谢谢。
我尝试了什么:
.
I tried the following code to do but no luck so far. I am struggling since 2 days. Anyone have any ideas then please share. Thank you.
What I have tried:
//My form
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.TextBoxFor(m => m.txtName)
<button type="submit" id="submit">Produce Page</button>
}
//My Modal
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal" aria-hidden="true">
...
<div class="modal-header">
...
<button type="button" class="close" onclick="CloseModalPopup();" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" onclick="CloseModalPopup();">Close</button>
<button type="button"><a href="~/MyHome/MyHome">Go to My Home</a></button>
</div>
</div>
My JavaScript code:
$(function () {
$('#submit').click(function () {
var value = $('#txtName').val();
if (value) {
$("#myModal").modal('show');
}
});
});
function CloseModalPopup() {
$("#myModal").modal('hide');
}
});
推荐答案
(function(){
(function () {
('#submit')。click(function(){
var value =
('#submit').click(function () { var value =
('#txtName')。val();
if(value){
('#txtName').val(); if (value) {
这篇关于模态弹出关闭按钮在MVC项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文