Opened 3 years ago

Closed 3 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)

Custom.js (163.3 KB) - added by Devidas Bhange 3 years ago.
default.js (1.5 MB) - added by Devidas Bhange 3 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 3 years ago by Jakub Ś

Status: newpending

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.

Changed 3 years ago by Devidas Bhange

Attachment: Custom.js added

Changed 3 years ago by Devidas Bhange

Attachment: default.js added

comment:2 Changed 3 years ago by Devidas Bhange

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 3 years ago by kkrzton

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 which 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.

Last edited 3 years ago by kkrzton (previous) (diff)

comment:4 Changed 3 years ago by Jakub Ś

Resolution: invalid
Status: pendingclosed

This solution is working. I'm closing the ticket.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy