简体   繁体   English

Kendo窗口中的Kendo UI编辑器

[英]Kendo UI Editor inside Kendo Window

I am using a kendo-editor for WYSIWYG text editing and works great. 我使用kendo-editor进行所见即所得的文本编辑,效果很好。 But when the kendo-editor is inside a kendo-window I get this error 但是当kendo-editor kendo-window我会收到此错误

TypeError: Cannot read property 'open' of null
    at Widget.extend._createContentElement (webpack:///./kendo-ui/js/kendo.editor.js?:426:16)
    at Widget.extend._initializeContentElement (webpack:///./kendo-ui/js/kendo.editor.js?:512:40)
    at new Widget.extend.init (webpack:///./kendo-ui/js/kendo.editor.js?:282:18)
    at HTMLTextAreaElement.eval (webpack:///./kendo-ui/js/kendo.core.js?:3104:32)
    at Function.jQuery.extend.each (webpack:///../Scripts/jquery.js?:374:23)
    at jQuery.fn.jQuery.each (webpack:///../Scripts/jquery.js?:139:17)
    at $.fn.(anonymous function) [as kendoEditor] (webpack:///./kendo-ui/js/kendo.core.js?:3103:26)
    at createIt (webpack:///./kendo-ui/js/kendo.angular.js?:192:31)
    at createWidget (webpack:///./kendo-ui/js/kendo.angular.js?:168:20)
    at link (webpack:///./kendo-ui/js/kendo.angular.js?:681:34)

occuring in kendo.editor.js . 发生在kendo.editor.js中

iframe = $("<iframe />", { title: editor.options.messages.editAreaTitle, frameBorder: "0" })[0];

$(iframe)
    .css("display", "")
    .addClass("k-content")
    .insertBefore(textarea);


iframe.src = src;

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

$(iframe).one("load", function() {
    editor.toolbar.decorateFrom(doc.body);
});

doc.open(); // throws TypeError: Cannot read property 'open' of null
doc.write(

Note there's no error and it works great when the kendo-editor is not inside the kendo-window . 请注意,没有错误,并且当kendo-editor不在kendo-window内时,它会很好地工作。

Has anyone ever run into something like this and what's a solution / workaround? 有没有人遇到过这样的事情,什么是解决方案/解决方法?

The Kendo Editor instance should be called after the kendo Window has been opened, in other words after its container is in the DOM. Kendo编辑器实例应在打开Kendo窗口后调用,换句话说,是在其容器位于DOM中之后调用。

You should create the kendoEditor in the open event: 您应该在open事件中创建kendoEditor:

$("<div/>").kendoWindow({
  open: function(e){
    $("#myTextarea").kendoEditor();
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM