Jquery对话框打开/关闭

时间:2012-07-02 16:43:42

标签: jquery-ui modal-dialog jquery-ui-dialog

我正在尝试在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>

3 个答案:

答案 0 :(得分:1)

尝试$('#rejectiondiv')。dialog('open');

答案 1 :(得分:1)

将您的javascript放在<head>代码中,并在<div>之外的对话<form>。工作示例:http://jsfiddle.net/T4gz3/

答案 2 :(得分:0)

$("#rejctbutton")
.button()
.click(function () {
$("#rejectiondiv").dialog("open");
return false;
});

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

modal-close-question