下拉列表更改函数不会在 Jquery 对话框中触发

Dropdownlist change function doesn't fire in Jquery dialog

本文关键字:对话框 Jquery 函数 下拉列表      更新时间:2023-09-26

我需要根据从Jquery对话框中的第一个下拉列表中选择的值更新数据库中的第二个下拉列表。

.ASPX

<asp:UpdatePanel ID="upnl" OnLoad="upnl_Load" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="dv" style="display: none;" title="Tile">
<table>
    <tr>
        <td>Parent</td>
        <td>
            <asp:DropDownList ID="ddlDialog1" runat="server" /></td>
    </tr>
    <tr>
        <td>Child</td>
        <td>
            <asp:DropDownList ID="ddlDialog2" runat="server" /></td>
    </tr>
</table>
</div >
</ContentTemplate>
</asp:UpdatePanel>

杰奎里

function ShowDialog() {
jQuery(document).ready(function () {
    $("#dv").dialog({
        draggable: true,
        modal: true,
        width: 500,
        height: 400
    });
});
}
jQuery(document).ready(function () {
$("#<%= ddlDialog1.ClientID %>").change(function () {
   //This doesn't fire
    __doPostBack('<%= upnl.ClientID %>', "DialogOnChange");
});
});

这里的问题是,当我从第一个下拉列表中选择不同的值(ddlDialog1)时,如何更改函数不会触发。

知道吗?

因为$("#dv").dialog();更改了您的文档。

您必须在

对话框打开后绑定$("#<%= ddlDialog1.ClientID %>")

$("#dv").dialog({ 
  //...,
  open: function(){
    //..bind item in this dialog
  },
});

这可能会对您有所帮助。

$('#ddlDialog1').change(function(){            
        alert(Selected Value : + $('#ddlDialog1').val());    
});​