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
thisto a variable and use it in another scopeor you can get the value first and then use it