我有這樣的代碼:KnockoutJS最大調用堆棧大小超出
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被稱爲: 未捕獲的RangeError:最大調用堆棧大小超過
有人能告訴我問題在哪裏嗎?
謝謝!
編輯:
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()
};
你能提供的EditItem映射的JavaScript? – RodneyTrotter
已更新。謝謝 – functionalCode