Opened 9 years ago
Closed 9 years ago
#14627 closed Bug (invalid)
CKEditor shows last configuration
Reported by: | Devidas Bhange | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.0 |
Keywords: | Cc: | rohitkadam@… |
Description
Hi,
We are using CKEditor and having problem while loading the template dynamically for below scenario.
We have two buttons, on the click of first button a configuration templates is loading and for second button clicks, second configuration templates loaded.
But when user clicks on first button again then CKEditor shows last configuration templates.
We also verified that the template file (*.js) is loading every time but CKEditor not showing the updated template file.
Please look into this issue and let us know if there is anything we missed to set the configurations.
Thanks in advance,
Attachments (2)
Change History (6)
comment:1 Changed 9 years ago by
Status: | new → pending |
---|
Changed 9 years ago by
Changed 9 years ago by
Attachment: | default.js added |
---|
comment:2 Changed 9 years ago by
Hi j.swiderski,
We are planning to purchase the ckeditor but looking for the below functionality to be work:
Here is my javascript to load the template into ckeditor :
function getDefaultTemplate() {
javascript: CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.config.templates_files = ckeditor/plugins/templates/templates/default.js?;
javascript: CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.commands.templates.exec();
}
function getCustomTemplate() {
javascript: CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.config.templates_files = Javascripts/Plugins/Custom.js?;
javascript: CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.commands.templates.exec();
}
So when I call the firs function getDefaultTemplate() it loads the template from default.js and then I called the second function getCustomTemplate() then it loads the template from Custom.js
but now when I call the first function getDefaultTemplate() again then it does not load the default.js it show the template loaded from the custom.js file.
help would be appreciated
comment:3 Changed 9 years ago by
Hello, your code is a proper approach but needs a little tuning.
First, you should name your template groups differently, so for default.js you will have CKEDITOR.addTemplates("default", ... )
and for custom.js - CKEDITOR.addTemplates("custom", ... )
.
There is no need to try to load templates every time the button is clicked, just load templates once using config.template_files like:
config.templates_files = [ 'path/default.js', 'path/custom.js' ];
And then you can tell CKEditor which templates should be used via config.templates. This is the option wich should be switch dynamically on button click, so:
function getDefaultTemplate() { CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.config.templates = 'default'; CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.commands.templates.exec(); } function getCustomTemplate() { CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.config.templates = 'custom'; CKEDITOR.instances.ctl00_ContentPlaceHolder1_ckEditorCanvas.commands.templates.exec(); }
I will be happy to hear from you if it solved your issue.
comment:4 Changed 9 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
This solution is working. I'm closing the ticket.
Please provide reduced sample allowing to reproduce this issue in default CKEditor. I'm talking about HTML file (with js files if needed) which can be put into default CKEditor samples folder and will show this issue.