我正从knockoutjs处带走以下错误。 它清楚地知道,“地区”是大部分时间,因为“土地倡议”表明“地区”正在显示,但有时会以错误冻结。
Uncaught Error: Unable to parse bindings.
Message: TypeError: Object #<Object> has no method AreaNames ;
Bindings value: foreach: ActiveDay().AreaNames()
相关守则:
<ul data-bind="foreach: ActiveDay().AreaNames()">
<li data-bind="text: $data"></li>
</ul>
var scheduleModel = function (shiftCellToggle) {
var vm = this;
vm.ActiveDay = ko.observable({ AvailableShiftCategories: [] });
vm.CustomMapping = {
Weeks : {
create: function (options) {
var week = new scheduleWeekModel(vm, shiftCellToggle);
ko.mapping.fromJS(options.data, week.CustomMapping, week);
return week;
}
}
};
}
var scheduleWeekModel = function (scheduleModel, shiftCellToggle) {
var vm = this;
vm.CustomMapping = {
Days : {
create: function (options) {
var day = new scheduleDayModel(scheduleModel, shiftCellToggle);
ko.mapping.fromJS(options.data, day.CustomMapping, day);
return day;
}
}
};
var scheduleDayModel = function (scheduleModel, shiftCellToggle) {
var vm = this;
vm.CustomMapping = {
AvailableShiftCategories : {
create: function (options) {
var availableShiftCategory = new availableShiftCategoryModel(scheduleModel, vm, shiftCellToggle);
ko.mapping.fromJS(options.data, availableShiftCategory.CustomMapping, availableShiftCategory);
return availableShiftCategory;
}
}
};
vm.AreaNames = ko.observableArray([]);
var viewModel = new scheduleModel(createShiftToggle());
ko.applyBindings(viewModel);