【问题标题】:Kendo UI Editor inside Kendo WindowKendo Window 中的 Kendo UI 编辑器
【发布时间】:2015-11-25 00:08:00
【问题描述】:

我使用kendo-editor 进行所见即所得的文本编辑,效果很好。但是当kendo-editor inside 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)

发生在 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(

请注意,当kendo-editor 不在kendo-window 内时,它不会出现错误。

有没有人遇到过这样的事情,有什么解决方案/解决方法?

【问题讨论】:

  • 你确定你的剑道编辑器是在剑道窗口创建后设置的吗?如果不尝试在 kendoWindow 的“打开”事件中调用 kendoEditor(或要绑定的对象)
  • 这是问题所在。随意添加作为答案,我会接受:)

标签: javascript html kendo-ui kendo-window kendo-editor


【解决方案1】:

剑道编辑器实例应该在剑道窗口打开之后调用,换句话说,在它的容器在 DOM 中之后。

您应该在 open 事件中创建 kendoEditor:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多