Changing configuration options of a CKEditor instance
I have a CKEditor instance attached to a textarea
. I would like to be able change some configuration options of this instance after its creation, depending on the va开发者_如何学编程lue of another form field.
Is it possible to do this, or else it's necessary to destroy the instance and attach another one, with the new options? I've checked in the CKEditor docs, but found nothing about this subject.
Thanks in advance,
Usually the configuration options will work only upon creation. You might be able to perform some tricks and so get some of the options to work at a later time, but that's usually more difficult.
I know I am late. But I would like to share this.
If you decide on a config before the creation of a ckeditor instance and plan on overriding those configurations, it's not possible. You can definitely add more config options but cannot change any existing option.
Say you pass a config object while creation of an instance.
CKEDITOR will internally call replace function to create the instance. Which will, in turn, check if anything is present in config.js.
You provide some extra config option and also, you try to override any existing option, for eg., toolbar.
Internally, CKEDITOR will do an extend and will try to merge already existing config object and the new config object provided by config.js and finally create a new config object which it will use to create the instance.
When it extends, i.e tries to merge both the config object, it will take all the new config options and assign to final new config object. But, for existing config options which you tried to override in config.js, it will take the original option and assign to this new config object.
Hence, whatever you had provided to override existing config object is lost.
One option which you have is to destroy the current instance and use your new config object to create the instance.
I hope I was able to explain.
精彩评论