2

我正在尝试在 jquery 中创建一个模型对话框。我想让我的按钮打开对话框。目前,一旦打开它,它也会关闭它。我从来没有告诉它关闭它,但是当我单击按钮时它会打开然后立即关闭。知道为什么吗?

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>

<body>
<form id="form1" runat="server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui. googlecode.com/svn/tags/latest/external/jquery. bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://jquery-ui. googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>

<asp:Button ID="rejctbutton" runat="server" Text="Reject" />
<div id="rejectiondiv">
<h3>
Reason of Rejection for Insurance Claim
</h3>
<h4>
This will email the borrower the reason for the rejection.
</h4>
<asp:Label ID="rejectLabel" runat="server" Text="Reason"></asp:Label>
<asp:TextBox ID="rejectTB" runat="server"></asp:TextBox>
</div>

<script type="text/javascript">
$("#rejectiondiv").dialog({ autoOpen: false, modal: true })
$("#rejctbutton")
.button()
.click(function () {
$("#rejectiondiv").dialog("open");

});
</script>
</form>
</body>
</html>
4

3 回答 3

1

将您的 javascript 放在您的<head>标签中,并将您的对话框<div>放在<form>. 工作示例:http: //jsfiddle.net/T4gz3/

于 2012-07-02T16:57:37.500 回答
1

试试 $('#rejectiondiv').dialog('open');

于 2012-07-02T16:53:40.223 回答
0
$("#rejctbutton")
.button()
.click(function () {
$("#rejectiondiv").dialog("open");
return false;
});

也许这会有所帮助。我在另一个回复中找到了这个解决方案:

模态关闭问题

于 2015-07-02T09:23:10.600 回答