【问题标题】:CKeditor - Inline events and callbacksCKeditor - 内联事件和回调
【发布时间】:2014-05-13 03:52:54
【问题描述】:

我正在使用 ckeditor 编辑内联文本。我发现的问题是,当 ckeditor 再次“关闭”或隐藏时,我看不到一种防御性的方式来查看事件。正常的行为是将 contenteditable 设置为 true 的元素,一旦用户点击它就会触发编辑器。

我想要的是通过自定义事件启动编辑器,比如双击,一旦编辑器“关闭”/隐藏,我想从元素中删除 ckeditor 实例,使其再次变为“正常” .但我在任何地方都没有看到,当然你可以使用 .blur() 事件,但我认为这不是一个好主意。

所以目前我正在做的是监听 dblclick 事件,然后:

edit: (e)  =>
    f = $(e.currentTarget)
    f.attr "contenteditable", true
    id = f.attr("id")
    $("##{id}").draggable({ disabled: true })
    $("##{id}").resizable({ disabled: true })
    if CKEDITOR.instances[id]
        CKEDITOR.instances[id].destroy();
    editor = CKEDITOR.inline id
    $(e.currentTarget).focus()


element.blur((el) =>
    f =  $(el.currentTarget)
    CKEDITOR.instances[f.attr("id")].destroy();
    f.removeClass 'cke_focus'
    f.addClass 'cke_editable'

如果有一个本地回调,你知道 ckeditr 现在已隐藏,我会很高兴,也许我错过了它??

【问题讨论】:

    标签: jquery html coffeescript ckeditor


    【解决方案1】:

    好的,如果有人对此有疑问,我在阅读文档后就是这样做的。请记住,这是一个主干.js 应用程序:

    ({
      edit: (function(_this) {
        return function(e) {
          var editor, f, id, o_html, pk;
          f = $(e.currentTarget);
          f.attr("contenteditable", true);
          id = f.attr("id");
          pk = f.data("pk");
          $("#" + id).draggable({
            disabled: true
          });
          $("#" + id).resizable("destroy");
          editor = CKEDITOR.inline(id);
          o_html = "";
          editor.on("dataReady", function() {
            return editor.focus();
          });
          editor.on("focus", function() {
            return o_html = f[0].innerHTML;
          });
          return editor.on("blur", function(e) {
            var n_html, view;
            console.log(o_html);
            n_html = f[0].innerHTML;
            if (o_html !== n_html) {
              console.log("update data on server");
            }
            editor.destroy();
            $("#" + id).draggable({
              disabled: false
            });
            view = new PageView;
            return view.initResizable(id);
          });
        };
      })(this)
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-07
      • 2013-05-07
      • 1970-01-01
      相关资源
      最近更新 更多