I have this code:
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);
}
});
};
When self.EditItemPopup is called once everything works fine, but when it is called a second time I get this error: Uncaught RangeError: Maximum call stack size exceeded
Could someone tell me where the problem is?
Thanks!
EDIT:
EditItem mapping:
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()
};