I'm trying to trigger ckeditor in two bootstrap tabs. The problem is that I need to have the same textarea input name "body" which automatically prevents the second instance of ckeditor to launch. I do need this because both instances will input to the same field on a database. From what i've read i'm led to believe this might be possible to resolve using some jquery bootstrap tab events but i'm not getting the grips of it. I guess i need to be able to disable the first instance on toggle for the second one to be triggered but I'm not really sure on how to do that. Can anyone share some insights on how to achieve this?

Elaborating a little bit more, i've been trying stuff around these hypothesis but nothing is working...

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    var editor = CKEDITOR.instances['body'];
    if (editor) { editor.destroy(true); }
    CKEDITOR.replace('body');
});

or

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    if (CKEDITOR.instances['body']) {
    CKEDITOR.instances['body'].destroy();

or

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        function startEditor(){
            if (CKEDITOR.instances.body){
                CKEDITOR.instances[body].destroy(true);
                CKEDITOR.replace( 'body');
            }
        }
        function destroyEditor(){
            if (CKEDITOR.instances.body){
                CKEDITOR.instances[body].destroy(true);
            }
        }
        $(e.relatedTarget).destroyEditor();
        $(e.target).startEditor();
    });
有帮助吗?

解决方案

After hours around this I found out the answer, and a very very basic one. Just had to call ckeditor by class and not by textarea.

class="ckeditor"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top