• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 54
  • Last Modified:

Using ck editor inline

dear all

i have 2 ck editors in my page where below is my code that i am using :

                                                       
    <div id="CkEditor_Details" runat="server" class="LiteralStyle_N_WithBorder" contenteditable="true"
                                                                style="height: 66px">
                                                            </div>

Open in new window


below is how i am declaring the editor:
 
var m_CkEditor_Details = document.getElementById('<%=CkEditor_Details.ClientID%>').id;
            setCkEditorToolbar(m_CkEditor_Details);
function setCkEditorToolbar(m_CkEditor) {
    
    var config = {};

    config.toolbarGroups = [
    { name: 'document', groups: ['mode', 'document', 'doctools'] },
    { name: 'clipboard', groups: ['clipboard', 'undo'] },
    { name: 'editing', groups: ['find', 'selection', 'spellchecker', 'editing'] },
    '/',
    { name: 'forms', groups: ['forms'] },
    { name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
    { name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align', 'bidi', 'paragraph'] },
    { name: 'links', groups: ['links'] },
    { name: 'insert', groups: ['insert'] },
    '/',
    { name: 'styles', groups: ['styles'] },
    { name: 'colors', groups: ['colors'] },
    { name: 'tools', groups: ['tools'] },
    { name: 'others', groups: ['others'] },
    { name: 'about', groups: ['about'] }
    ];

    config.removeButtons = 'Source,Save,NewPage,Preview,Print,Templates,PasteText,Form,Checkbox,Radio,TextField,Textarea,Select,Button,HiddenField,Blockquote,CreateDiv,Anchor,Flash,HorizontalRule,Smiley,PageBreak,Iframe,ShowBlocks,About';
    CKEDITOR.disableAutoInline = true;
    config.autoParagraph = false;
    config.resize_enabled = true;
    //Editor instances have to be destroyed explicitly first.
    try{
        var editor = CKEDITOR.inline(m_CkEditor, config);
    } catch (e) {

    }
    
    
};

Open in new window


Editor instances have to be destroyed explicitly first.
how can i do that while using 2 instances of ck editot
0
pamela rizk
Asked:
pamela rizk
  • 2
1 Solution
 
Pravin AsarPrincipal Systems EngineerCommented:
Look into (CKEDITOR.instances); it  is an array of instances you should loop it to destroy each one:

for (key in CKEDITOR.instances) {
    CKEDITOR.instances[key].destroy(true);
}
0
 
pamela rizkDeveloperAuthor Commented:
where shoudl i add this code?
should i add it before addind new instances ?
0
 
Pravin AsarPrincipal Systems EngineerCommented:
This all depends , when you want to remove/destroy an instance.


Here is a working example:

https://jsfiddle.net/pravinasar/xpvt214o/107654/


This shows, how you can destroy an instance explicitly
Core part of the code is

CKEDITOR.instances['editor1'].destroy(true);

Which event should trigger this action is upto you.

Good Luck!
0

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now