【问题标题】:jquery chosen select trigger not working in ie11jquery选择的选择触发器在ie11中不起作用
【发布时间】:2016-01-23 05:51:02
【问题描述】:

我正在使用 jquery selected select 插件来动态显示和选择多个选项。我可以在 chrome 和 ie11 上的 UI 上选择多个选项,但是在动态检索已选择的选项时,chrome 工作得很好,但 ie11 失败了。代码如下:

HTML:

<div class="row-fluid">
                <div class="span2">
                    <div class="editor-label" style="width:150px;">
                        @Html.Label("User to Impersonate")
                    </div>
                    <div class="editor-field">
                        @Html.DropDownList("usersImpersonationId", new SelectList(Model, "WindmillUserId", "Username"), new { @class = "chosen", multiple = "multiple" })
                    </div>
                </div>
            </div>

jquery:

$(".chosen").chosen({
                disable_search_threshold: 10,
                no_results_text: "Oops, nothing found!",
                width: "50%"
            });

..................

function GetImpersonatedUsers() {
                $.ajax({
                    url: "/Impersonate/GetAllUsersImpersonated?UserId=" + $('#impersonationId').find('option:selected').val(),
                    type: "GET"
                })
                .done(function (jsonResult) {
                    console.log('jsonResult => %o', jsonResult);
                    $("#usersImpersonationId > option").each(function () {
                        $(this).removeAttr("selected");
                    });
                    for (var i = 0; i < jsonResult.length; i++) {
                        $('#usersImpersonationId option[value="' + jsonResult[i] + '"]').attr("selected", "selected");
                    }
                    $('#usersImpersonationId').trigger("liszt:updated");
                    //$('#usersImpersonationId').trigger('chosen:updated');

                })
                .fail(function (jqXHR, textStatus) {
                });
            };

当我动态加载选项并触发控件更新时,它在 chrome 中工作,html 如下(我可以看到 li 选项为 class= search-choice:

但在 ie11 的情况下,即使在触发更新后也不会添加 li 选项:

我有什么遗漏或 ie11 的行为应该如此吗?

【问题讨论】:

    标签: javascript jquery jquery-chosen


    【解决方案1】:

    IE11 的控制台日志说什么?它是否抛出任何错误或警告?

    【讨论】:

    • 您应该将此添加为对问题的评论而不是答案
    • 没有引发异常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-08
    相关资源
    最近更新 更多