When setting a value to an object in the model, the following error appears:
Uncaught TypeError: Cannot read property 'open' of null
The stack trace finishes with this line:
Widget.extend._createContentElement @ kendo.web.js:67057
that on the kendo.web.js translates to the following:
doc.open();
The stack trace starts with this line:
vm.homework.set("timetableId", -1);
The vm object is the "virtual model" it is an instance of the kendo.observable model, homework is an object of the model, it is check if it's initialize before setting it like this:
if (vm.homework !== undefined) {
vm.homework.set("id", -1);
vm.homework.set("timetableId", -1);
vm.homework.set("title", "");
What is weird is that the "vm.homework.set("id",-1)" doesn't throw the exception.
I tried changing the set to "vm.homework.timetable=-1" it does not throw the error, but the error persist on the next "set" line.
I'll attach a screen shot of the hole stack trace.
The kendo.observable is set like this:
models = (function (models) {
models.homeworkModel = kendo.observable({
homework: {
id: -1,
timetableId: -1,
title: "",
details: "",
availableTime: new Date(),
dueDate: new Date(),
lessonGroupId: null,
isLessonAssign: true,
links: [],
homeworkStudents: [],
homeworkResources: []
},
lesson: -1,
//Behaviour
init: init,
});
var vm = models.homeworkModel;
return models;
function init(lessonId) {
$.blockUI();
resetVm();
vm.homework.set("timetableId", lessonId);
vm.set("lesson", lessonId);
}
function resetVm() {
if (vm.homework !== undefined) {
vm.homework.set("id", -1);
vm.homework.set("timetableId", -1);
vm.homework.set("title", "");
vm.homework.set("details", "");
vm.homework.set("availableTime", new Date());
vm.homework.set("dueDate", new Date());
vm.homework.set("isLessonAssign", true);
vm.homework.set("lessonGroupId", null);
vm.homework.set("links", []);
vm.homework.set("homeworkStudents", []);
vm.homework.set("homeworkResources", []);
}
}
})(typeof models != "undefined" ? models : {});