-
Notifications
You must be signed in to change notification settings - Fork 28
watch on array does not work correctly #8
Copy link
Copy link
Open
Labels
Description
If we watch to a existing array and then add items to the existing array, the watch function will not work correctly:
Aj.init(function ($scope) {
$scope.data = {
list: []
};
$scope.snippet("ul").bind($scope.data, {
list:{
_duplicator: "li",
_item: {
"nnn": {
_selector: ".x-watch",
_watch: {
_fields: ["name"],
_cal: function(v){
console.log("cal", v);
return v+"-watched";
}
},
_render: function(target, nv, ov, ctx){
console.log("args", arguments);
console.log("idx:", ctx.getArrayAssistant().getIndex());
target.text(nv);
}
}
}
}
});
$scope.data.list.push({
name: "name-" + i
});
}Workaround is to reassign a new array reference to replace the existing array:
$scope.data.list = Aj.util.clone($scope.data.list);
$scope.data.list.push({
name: "name-" + i
});Reactions are currently unavailable