我有这个代码:
self.EditItemPopup = function (something) {
var temp = ko.mapping.toJS(something);
//self.ItemToEdit = ko.mapping.fromJS(temp, EditItem, self.ItemToEdit);
ko.mapping.fromJS(temp, EditItem,self.ItemToEdit);
self.FindMatchingCategory(something.CategoryID());
$("#editItemPopup").dialog("open");
};
self.FindMatchingCategory = function (categoryID) {
ko.utils.arrayForEach(self.ViewModel().Categories(), function (categoryToFind) {
if (categoryToFind.CategoryID() == categoryID) {
self.ItemEditCategory(categoryToFind);
}
});
};
当 self.EditItemPopup 在一切正常时被调用,但是当它被第二次调用时我得到这个错误: Uncaught RangeError: Maximum call stack size exceeded
有人能告诉我问题出在哪里吗?
谢谢!
编辑:
EditItem 映射:
var EditItem = {
ItemName: ko.validatedObservable().extend({
required: {
message: "Please enter an item name.",
insertMessages: false
}
}),
ItemCost: ko.validatedObservable().extend({
required: {
message: "Please enter a valid price.",
insertMessages: false
}
}),
CategoryID: ko.observable()
};