gpt4 book ai didi

javascript - valueHasMutated() - 与 IE 8 兼容

转载 作者:行者123 更新时间:2023-11-28 05:56:52 25 4
gpt4 key购买 nike

我有一个可观察数组,其中填充了诸如

之类的对象
{
thisId: value.id,
nom: value.nom,
isChecked:check
};

填充observableArray的代码

self.fullFilter = function() {
var check;
self.thisObservableArray.removeAll();
self.anOther1.removeAll();
self.anOther2.removeAll();
$.get("data/"+self.currentOngletId()+"?ajax=1", function(data) {
$.each(data, function(i, item) {
$.each(item, function(j, value) {
check = null;
switch (i) {
case 0:
try{
if(value.observable_value.length > 0){
check = "checked";
}
var elem = {
thisId: value.id,
nom: value.nom,
isChecked:check
};
self.thisObservableArray().push(elem);
} catch(e){
console.warn('fullfilter -> observable_value '+e)
}
break;
case 1:
//an other same code different variables
break;
case 2:
//an other same code different variables
break;
}
});
});
try {
self.thisObservableArray.valueHasMutated();
self.anOther1.valueHasMutated();
self.anOther2.valueHasMutated();
} catch(e){
self.error("fullfilter",e);
}
});
};

当我尝试使用 IE 8 时,出现此错误

Unable to parse bindings

Bindings value: attr:{for:'thisObservableArray-'+$data.thisId}

Message : Identifier, string or number expected

发现错误的 View 部分

<fieldset>
<legend>Statut</legend>
<ul data-bind="foreach: thisObservableArray()">
<li>
<div class="form-group">
<label data-bind="attr:{for:'thisObservableArray-'+$data.thisId}">
<input class="observable-input" data-bind="attr:{id:'thisObservableArray-'+$data.thisId, name:'thisObservableArray['+$data.id+']', checked: $data.isChecked}" type="checkbox"/>
<span data-bind="text: $data.nom"></span>
</label>
</div>
</li>
/ul>
</fieldset>

最佳答案

IE8 不支持兼容模式下的属性选择器。

您需要有一个 Doctype (<!doctype html>)触发标准模式。

Article

DocTypes

enter image description here

关于javascript - valueHasMutated() - 与 IE 8 兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37594232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com