jQuery模式对话框
我是在jQuery中进行开发的新手,所以我可能这样做是错误的.我正在将一个表单加载到一个模式对话框中,并试图为该表单中的按钮分配一个Click事件,但似乎无法使任何事情发生.以下是代码.先谢谢你.
JQuery:
选择 | 换行 | 行号
- jQuery(document).ready(function()
- {
- jQuery("a[@id*=form]").click(function()
- {
- jQuery("#dialog").dialog({
- modal: true,
- autoOpen: false,
- width: 600,
- dialogClass: "flora",
- overlay: {opacity: 0.5, background: "black"}
- });
- jQuery("#dialog").load(jQuery(this).attr("href") + " form[@id*=order] fieldset",setFormClick());
- jQuery("#dialog").dialog("open");
- return false;
- });
- function setFormClick()
- {
- jQuery('#dialog input[@id*=update]').click(function()
- {
- alert("It works");
- });
- }
- }
.aspx主页
选择 | 换行 | 行号
- <%@ Page Language="C#" AutoEventWireUp=true CodeFile="Order_02_ServiceAdmin.aspx.cs" Inherits="_Default" %>
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link href="/custom/applications/appStyles.css" rel="stylesheet" type="text/css" media="screen" />
- <link rel="stylesheet" href="/custom/applications/jquery.ui-1.5/themes/flora/flora.dialog.css" type="text/css" media="screen" />
- <script type="text/javascript" src="/custom/applications/jquery.ui-1.5/jquery-1.2.6.js"></script>
- <script type="text/javascript" src="/custom/applications/jquery.ui-1.5/ui/ui.core.js"></script>
- <script type="text/javascript" src="/custom/applications/jquery.ui-1.5/ui/ui.dialog.js"></script>
- <script type="text/javascript" src="javascript/Order_02_functions.js"></script>
- </head>
- <body>
- <form id="Order_02" runat="server">
- <div id="dialog"></div><!--Form inserted here-->
- <!--Irrelevant code here-->
- <div style="float: left; width: 40%; height: 100%;">
- <fieldset style="overflow: auto">
- <legend>Selected Services</legend>
- <asp:table ID="servicesSelected" runat="server" Caption="No Services Selected" EnableViewState="false">
- <asp:tableheaderrow CssClass="eth">
- <asp:tableheadercell>
- Service (Click to input details)
- </asp:tableheadercell>
- <asp:tableheadercell>
- </asp:tableheadercell>
- <asp:tableheadercell>
- Status
- </asp:tableheadercell>
- <asp:tableheadercell>
- Notes
- </asp:tableheadercell>
- </asp:tableheaderrow>
- </asp:table>
- </fieldset>
- </div>
- <!--Irrelevant code here-->
- </form>
- </body>
- </html>
主页的.cs代码构建上面的表格,添加jQuery将点击事件附加到的链接.这些链接如下所示:
服务描述
.aspx表单代码
选择 | 换行 | 行号
- <%@ Page Language="C#" AutoEventWireUp=true CodeFile="Order_02b_Form_01.aspx.cs" Inherits="_Default" %>
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <link href="/custom/applications/appStyles.css" rel="stylesheet" type="text/css" media="screen" />
- </head>
- <body>
- <form id="order01" runat="server">
- <fieldset id="01" class="generalFieldsetStyle">
- <legend></legend>
- <p>
- <label for="t01_COUNTY"><span class="importantText" >*</span>County: </label>
- <asp:textbox ID="t01_COUNTY" runat="server" MaxLength="30"/><span id="reqCounty" style="color: red; visibility: hidden">Please enter the name of the county</span><br/>
- <label for="t01_STATE_PROVINCE">
- <span class="importantText">*</span>State:
- </label>
- <asp:dropdownlist id="t01_STATE_PROVINCE" runat="server">
- <asp:listitem value="" Text=""></asp:listitem>
- <asp:listitem value="NY" Text="NY"></asp:listitem>
- </asp:dropdownlist>
- <span id="reqState" style="color: red; visibility: hidden">Please select a state</span><br/>
- <input id="update01" name="update01" type="button" value="Update" />
- </p>
- </fieldset>
- </form>
- </body>
- </html>
.cs代码主要只是生成下拉列表的选项.