CKEDITOR.replace() undefined
CKEDITOR.replace() undefined
我正在使用主干表单,我想用CKEDITOR替换我的textArea。
此代码返回:UncaughtTypeError:undefined不是函数(对于CKEDITOR行)
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;
}
});
});
然而,它与这个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;
}
});
});
知道为什么第一个代码不起作用吗?
您可以将this
保存到一个变量中,并在另一个作用域中使用它
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);
});
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- /undefined在我的404错误日志中多次出现
- RequireJS向模块传递配置总是返回undefined
- JSON数组数据返回Undefined
- 为什么会出现错误,“UncaughtTypeError:undefined不是函数”
- Array.lenght = undefined
- mongoose.connect undefined不是一个函数
- JavaScript”;.方法“;返回undefined
- Uncaught TypeError:undefined不是函数-ember js
- Jquery - table.row(tr) is undefined
- jQuery可以't获取data-*属性值,返回undefined
- noty.js is returning undefined
- 将对象的列表c#传递给javascript:undefined变量时出错
- $routeParams is undefined
- 试图打印/调用/或提醒数组中的对象:Getting Undefined
- jQuery Mobile Undefined不是一个函数
- 替换变量时,JavaScript字符串replace()不起作用
- CKEDITOR.replace() undefined
- 调用replace方法时,TypeError: undefined不是函数
- Undefined不是对象(求值'value.phrase.replace')