jquery对话框和表单

8wigbo56  于 2021-09-23  发布在  Java
关注(0)|答案(2)|浏览(396)

我的jquery对话框未隐藏。加载页面时,它会自动调用并显示,而我将其属性设置为autopen为false。我设置了一个按钮,单击事件打开对话框。但并非徒劳
我的jquery代码在这里

$(document).ready(function () {
            $("#dialog").dialog({
                buttons: [{ text: "OK", click: function () { $(this).dialog("close") } }],
                modal: true,
                autoOpen: false
            });
            $('#btnpopup').click(function () {
                $('#dialog').dialog("open");
            });

我的html代码

<div >
            <asp:Button ID="btnpopup" runat="server" Text="Add Instruction" />
        </div>
        <div id="dialog">
             <table>
           <tr>
               <td>Title</td>
               <td>
                   <asp:TextBox ID="titlefield" runat="server"></asp:TextBox>

               </td>
                <td>Instruction Category</td>
               <td>
                   <select id="category"></select>

               </td>
           </tr>
          <tr>
              <FTB:FreeTextBox ID="FreeTextBox1" runat="server"></FTB:FreeTextBox>
          </tr>

       </table>
        </div>

包括图书馆

e<script src="Scripts/jquery-ui-1.12.1.js" ></script>

<script src="Scripts/jquery-3.6.0.js" type="text/javascript"></script>
<link href="Content/jquery.layout-1.4.3.css" rel="stylesheet" />
<link href="Content/jquery.ui.layout.css" rel="stylesheet" />
<link href="Content/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="Scripts/jquery-ui-1.12.1.js"></script>nter code here
cbwuti44

cbwuti441#

从您的代码来看,您似乎加载了两次jQueryUI库,所以它发生了冲突。只需在jquery库加载后使用它一次。请参阅下面的参考资料。

<script src="Scripts/jquery-3.6.0.js" type="text/javascript"></script>
<link href="Content/jquery.layout-1.4.3.css" rel="stylesheet" />
<link href="Content/jquery.ui.layout.css" rel="stylesheet" />
<link href="Content/themes/base/jquery-ui.css" rel="stylesheet" />
<script src="Scripts/jquery-ui-1.12.1.js"></script>
5uzkadbs

5uzkadbs2#

你好像忘了放最后一个花括号和括号了})这对我的截图有用

$(document).ready(function () {
        $("#dialog").dialog({
            buttons: [{
                text: "OK",
                click: function () {
                    $(this).dialog("close")
                }
            }],
            modal: true,
            autoOpen: false
        });
        $('#btnpopup').click(function () {
            $('#dialog').dialog("open");
        });
    })

代码笔

相关问题