Search code examples
ckeditor

CKEditor on Modal


I have a CkEditor 4.x on modal.. I try modal jQueryUI and Bootstrap modal.

When i show Ckeditor in modal and when i use its plugins, fields of plugin don't have a focus, and i can't set it with click. enter link description here . If i init CkEditor in body, then all OK. But if on modal.then lost focus

I use standart init for CkEditor

self.ckwys = CKEDITOR.replace('wysivgBlock', {
   height: 300
});

Solution

  • $.fn.modal.Constructor.prototype.enforceFocus = function () {
    modal_this = this
    $(document).on('focusin.modal', function (e) {
        if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length
        // add whatever conditions you need here:
        &&
        !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) {
            modal_this.$element.focus()
        }
    })
    

    };

    This code is solved my problem.