【发布时间】: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