【问题标题】:Jquery dialog open/closeJquery 对话框打开/关闭
【发布时间】:2012-07-02 16:43:42
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 那也是一样的。打开它然后立即关闭它
    【解决方案2】:

    将您的 javascript 放入您的 &lt;head&gt; 标记中,并将您的对话框 &lt;div&gt; 放在 &lt;form&gt; 之外。工作示例:http://jsfiddle.net/T4gz3/

    【讨论】:

      【解决方案3】:
      $("#rejctbutton")
      .button()
      .click(function () {
      $("#rejectiondiv").dialog("open");
      return false;
      });
      

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

      modal-close-question

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-03-07
        • 1970-01-01
        • 2010-09-26
        • 1970-01-01
        • 1970-01-01
        • 2012-11-10
        • 1970-01-01
        相关资源
        最近更新 更多