2

I'm trying to create a model dialog in jquery. I would like for my button to open up the dialog. Currently as soon as it opens it up it also closes it. I never tell it to close it but when i click the button it opens and then immediately closes. Any idea why?

<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>
Alex K.
  • 171,639
  • 30
  • 264
  • 288
auwall12688
  • 389
  • 3
  • 11
  • 23

3 Answers3

1

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

Krishna
  • 169
  • 1
  • 8
1

Put your javascript in your <head> tags and take your dialog <div> outside of the <form>. Working example: http://jsfiddle.net/T4gz3/

Conner
  • 30,144
  • 8
  • 52
  • 73
0
$("#rejctbutton")
.button()
.click(function () {
$("#rejectiondiv").dialog("open");
return false;
});

maybe this will help. I found this solution on another reply:

modal-close-question

Community
  • 1
  • 1
Deniz Kaplan
  • 1,549
  • 1
  • 13
  • 18