This is a migrated thread and some comments may be shown as answers.

Cannot read property 'open' of null when setting objects in model

3 Answers 618 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Laurence
Top achievements
Rank 1
Laurence asked on 27 Oct 2015, 03:04 AM

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 : {});​

 

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 29 Oct 2015, 08:19 AM

Hello Laurence,

 

in order to help you further, we will need to replicate the problem on our side. Most likely, a widget setup goes wrong somewhere. Please isolate your problem in a Dojo - we will debug it and determine the cause.

 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Laurence
Top achievements
Rank 1
answered on 29 Oct 2015, 04:23 PM

Hi Petyo,

I found that the problem was happening when I use the "editor", because I'm recycling my model I don't know what happens but the DOM related with this objects get's null and causes the problem. Then I removed the editor completely and now works fine.

0
Petyo
Telerik team
answered on 02 Nov 2015, 08:17 AM

Hello Laurence,

 

we should be able to assist you further if we replicate the problem on our side. In case you need further assistance, please isolate it in a Dojo.

 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Laurence
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Laurence
Top achievements
Rank 1
Share this question
or