我正在使用jquery选择的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如下(我可以看到带有class = search-choice的li选项:
我有什么遗漏或ie11的行为应该是这样吗?
答案 0 :(得分:-2)
IE11的控制台日志说什么?它是否会抛出任何错误或警告?