【问题标题】:Chosen search does not work with Jquery Dialog. Why?选择的搜索不适用于 Jquery 对话框。为什么?
【发布时间】:2012-04-26 07:44:53
【问题描述】:

这是我的代码

  var dlg = $("#transfer_client").dialog({
                dialogClass: "templateDialog",
                autoOpen: false,
                modal: true,
                zIndex: 1500,
                height: 200,
                width: 200,
                title: "Transfer Campaign to a different Client"
            });

        dlg.parent().appendTo(jQuery("form:first"));

其中 transfer_client 是 div 代码是:

 <div id="transfer_client" class="dialog position" title="Transfer to a different Client">
    <span>Client:</span>
    <asp:DropDownList runat="server" Height="30px" ID="ddlClients" DataTextField="ClientName"
        DataValueField="ClientID">
    </asp:DropDownList>
    <br />
    <br />
    <asp:Button runat="server" OnClientClick="return confirmSubmit();" ID="btnTranfer"
        Text="Transfer" OnClick="btnTranfer_Click" />
</div>

我在dlg.parent().appendTo(jQuery("form:first")); 之后尝试过$("#dropDownID").chosen() 或之前,但它不会使其可搜索。但是在没有任何对话框的情况下使用代码可以正常工作。知道如何让它在对话框中工作吗?

编辑:标记为已解决,因为这是对话框 js 中的一个错误。

【问题讨论】:

  • dialog() 不是标准 jQuery 的一部分。您必须使用某种插件,或者自己编写(扩展),关心共享 dialog() 的代码?
  • 我使用对话框作为docs.jquery.com/UI/Dialog

标签: jquery jquery-ui dialog jquery-chosen


【解决方案1】:

你看过issue #18 on github吗?

它解决了我的类似问题,基本上归结为增加搜索框的 CSS z-index

【讨论】:

    【解决方案2】:

    试试这个

    .chosen-container .chosen-results {
        position: fixed;
        z-index: 23423423423;
        height: 200px;
        width: 300px;
        background-color: white;
    }
    

    【讨论】:

    • 虽然这个代码块可以回答这个问题,但如果你能提供一些解释为什么会这样,那将是一个更好的答案。
    猜你喜欢
    • 2016-04-03
    • 1970-01-01
    • 2017-06-10
    • 2018-03-11
    • 1970-01-01
    • 2012-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多