0

Good afternoon,

I'm trying to get the kendoEditor from the knockout-kendo project (https://github.com/kendo-labs/knockout-kendo/) to work, but it keeps throwing the error 'Uncaught TypeError: Cannot read property 'body' of null'.

After a lot of debugging I got to the following lines of code (This code is taken directly from kendo.web.js):

iframe = $("<iframe />", { src: 'javascript:""', frameBorder: "0" })
    .css("display", "")
    .addClass("k-content")
    .insertBefore(textarea)[0];

wnd = iframe.contentWindow || iframe;
doc = wnd.document || iframe.contentDocument;

doc.open();
doc.write('STRIPPED FOR READABILITY');
doc.close();

In here it is trying to create an iframe which is used in the editor. See the source on (http://demos.kendoui.com/web/editor/index.html) for an example. However, iframe.contentWindow, iframe.document and iframe.contentDocument are all null. Logically, this code fails when trying to do doc.open(); and results in the aforementioned exception.

After a bit of searching StackOverflow came up with the following: Why is iframe.contentWindow == null?. There seems to be a problem with the readiness of the document.

Does someone has any idea on how to solve this? Or does anyone has experience with DurandalJS (not the new v2) and knockout-kendo?

I am using Durandal JS 1.2.0.

Thanks in advance.

EDIT

Script references to jquery, knockout and kendo ui and knockout-kendo are done via MVC Bundle.Config.

kendoEditor initialization is done via:

<textarea id="emailTemplate" data-bind="kendoEditor: content"></textarea>
Community
  • 1
  • 1
Rob Maas
  • 475
  • 2
  • 4
  • 13
  • Is this code contained within the `viewAttached()` function of your Durandal viewmodel? – Brett Sep 04 '13 at 12:48
  • The above code is from the kendo.web.js script file, which I reference just before closing the body tag. Using knockout-kendo, the kendoEditor is initialized in this way: – Rob Maas Sep 04 '13 at 14:45
  • The area is pretty explanatory. You are attempting to call something.body but that something object is null. either you are doing this or kendo is, but it is not an error from the code you are showing. – PW Kad Sep 04 '13 at 23:02
  • Rob also note that what you have created as an issue in the kendo knockout github is not an issue in the source code, it is an issue in your code. I would recommend deleting it... – PW Kad Sep 04 '13 at 23:05
  • Hi @PWKad, correct, it is an error in my project/source code. I'm asking here if anybode has expierence with this kinda problem. Sorry for the Github issue, I thought it was also used as a Q&A type of forum :) – Rob Maas Sep 05 '13 at 14:28
  • Gotcha, open your project and press Ctrl+Shift+F in Visual Studio and search for '.body' and if there are any places in your code that this appears, paste that code here, if it is showing up in the source code for Kendo, then look at what the method expects the object listed right before it to be. Place a breakpoint there in chrome or w/e and see what is NOT being passed, probably you are supposed to be passing a value somewhere with () but you are leaving off the () or something – PW Kad Sep 05 '13 at 14:45
  • I don't have experience with the Knockout-Kendo project/extension, but it's really simple to integrate Kendo into Durandal without it. – Brett Sep 06 '13 at 15:29

0 Answers0