CKEDITOR.replace()undefined [英] CKEDITOR.replace() undefined

查看:665
本文介绍了CKEDITOR.replace()undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用骨干表单,我想用CKEDITOR替换我的textArea。



此代码返回:Uncaught TypeError:undefined不是函数line)

  define(['jquery','backbone','backbone-forms','ckeditor'],
function($,Backbone,CKEDITOR){

var Form = Backbone.Form;
Form.editors.Wysiwyg = Form.editors.TextArea.extend({
className :'form-control wysiwyg',

render:function(){
Form.editors.Base.prototype.render.call(this);
this.setValue .value);

CKEDITOR.replace(this.el.getAttribute('name'));
/ *此时,在控制台中我可以得到:
* CKEDITOR.Editor,.Field ...
*但不是.replace,.remove ...
* /

return this;
}

});
});

但是,它与这个verison很好玩:

  define(['jquery','backbone','backbone-forms'],
function($,Backbone){

var Form = Backbone.Form;
Form.editors.Wysiwyg = Form.editors.TextArea.extend({
className:'form-control wysiwyg',

render:function ){
Form.editors.Base.prototype.render.call(this);
this.setValue(this.value);
require(['ckeditor'],function(CKEDITOR) {
CKEDITOR.replace(html_content); //无法取得这个!
});

return this;
}
b $ b});
});

任何想法为什么第一个代码不起作用?

这个保存到变量并在另一个范围中使用


$

b $ b

  render:function(){
var t = this;
Form.editors.Base.prototype.render.call(t);
t.setValue(t.value);

require(['ckeditor'],function(CKEDITOR){
CKEDITOR.replace(t.el.getAttribute('name'));
});

return t;

}

或者您可以先获取该值,然后使用

  var name = this.el.getAttribute('name'); 

require(['ckeditor'],function(CKEDITOR){
CKEDITOR.replace(name);
});


I'm using backbone-forms and I want to replace my textArea with CKEDITOR.

This code returns : Uncaught TypeError: undefined is not a function (for CKEDITOR line)

define(['jquery', 'backbone', 'backbone-forms', 'ckeditor'],
  function($, Backbone, CKEDITOR) {

  var Form = Backbone.Form;
  Form.editors.Wysiwyg = Form.editors.TextArea.extend({
    className: 'form-control wysiwyg',

    render: function() {
      Form.editors.Base.prototype.render.call(this);
      this.setValue(this.value);

      CKEDITOR.replace(this.el.getAttribute('name'));
      /* At this point, in the consol I can just get:
      *  CKEDITOR.Editor ,.Field ...
      *  But not .replace, .remove ...
      */

      return this;
    }

  });
});

However, it plays nice with this verison:

define(['jquery', 'backbone', 'backbone-forms'],
  function($, Backbone) {

  var Form = Backbone.Form;
  Form.editors.Wysiwyg = Form.editors.TextArea.extend({
    className: 'form-control wysiwyg',

    render: function() {
      Form.editors.Base.prototype.render.call(this);
      this.setValue(this.value);
         require(['ckeditor'], function(CKEDITOR){
           CKEDITOR.replace("html_content"); //can't get this!
         });

      return this;
    }

  });
});

Any idea why the first code doesn't work ?

解决方案

You can save this to a variable and use it in another scope

render: function() {
  var t = this;
  Form.editors.Base.prototype.render.call(t);
  t.setValue(t.value);

  require(['ckeditor'], function(CKEDITOR){
     CKEDITOR.replace(t.el.getAttribute('name'));
  });

  return t;

}

or you can get the value first and then use it

var name = this.el.getAttribute('name');

require(['ckeditor'], function(CKEDITOR){
   CKEDITOR.replace(name);
});

这篇关于CKEDITOR.replace()undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆