我有一个observable array
,我填写了像
{
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时,我有这个错误
无法解析绑定
绑定值:attr:{for:' thisObservableArray - ' + $ data.thisId}
消息:预期的标识符,字符串或数字
发现错误的视图部分
<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>