我正在使用主干形式,我想用 CKEDITOR 替换我的 textArea。
此代码返回: Uncaught TypeError: undefined is not a function(对于 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;
}
});
});
但是,它与这个版本很相配:
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;
}
});
});
知道为什么第一个代码不起作用吗?