I am trying to set the CKEditor instance to "readOnly" after the instance is fully loaded, but I get a Javascript error: Cannot call method 'setReadOnly' of null . When I enter it, the error comes from this line in ckeditor.js in the editor.setReadOnly method: this.editable().setReadOnly(a); This means that the editor exists, but the method / attribute editable (on the CKEditor instance) is not.
Below is my code, and I will explain it a bit. My application is a combination of GWT and Backbone. CKEditor itself is created using the Backbone code, but the parent is in GWT, so when I trigger the setEnabled action.
private native void setEnabledOnLoad(boolean enabled, String id) ; setEnabled: function(enabled) { this.editor.setReadOnly(!enabled); if(enabled){ this.editor.focusManager.focus(); } else { this.editor.focusManager.blur(); } }
The Backbone class has a listener for Namespace.Events.SET_ENABLED that runs setEnabled .
Is there another CKEditor event that I should listen to? The instanceReady event is not displayed on editable . What am I missing?
EDIT
this.editor is created in the Backbone class render function as follows:
this.editor = CKEDITOR.replace(this.$(this.id)[0], config);
The reason I don't add an instanceReady listener right after I create it is because the setEnabledOnLoad function setEnabledOnLoad called in GWT before the instance is fully initialized. This is the result of having code in two places. GWT said βOK, create an instanceβ, but Backbone did not finish by the time GWT moves to the next line of code and wants to set it on / off.
eleanor.mal
source share