-
Notifications
You must be signed in to change notification settings - Fork 26
Description
We have a problem on line 412 in latest knockout.viewmodel.2.0.3.js (tested also in previous version - same problem).
If viewmodel and model contains array deep in their structure, line 415 fires error when we call ko.viewmodel.updateFromModel function:
TypeError: viewModelObj is not a function
Code on this error:
"viewModelObj(tempArray);" -- here is viewModelObj classic JS array, not observ. function...
I temporarily solved by modifying the source code as follows:
Original code:
...
else {//Can't use indexer for assignment; have to preserve original mapping with push
viewModelObj(tempArray);
for (p = 0, length = modelObj ? modelObj.length : 0; p < length; p++) {
viewModelObj.pushFromModel(modelObj[p]);
}
}
...
New temporary code:
...
else {//Can't use indexer for assignment; have to preserve original mapping with push
if (viewModelObj instanceof Array) {
if (JSON.stringify(viewModelObj) != JSON.stringify(modelObj)) {
// TODO: update viewModelObj array by modelObj
...
}
} else {
viewModelObj(tempArray);
for (p = 0, length = modelObj ? modelObj.length : 0; p < length; p++) {
viewModelObj.pushFromModel(modelObj[p]);
}
}
}
...
Does anyone have the same problem? Maybe we have bad input data, bud with previous ko.mapping plugin updating model with same structure worked well.