How to use CKEditor in a Bootstrap Modal?

后端 未结 14 1389
名媛妹妹
名媛妹妹 2020-11-30 04:14

If I use the CKEditor plugin in an HTML page based on a Bootstrap template, it works great, however if I insert the editor on a Bootstrap Modal like this

<         


        
14条回答
  •  感动是毒
    2020-11-30 04:41

    This should help http://jsfiddle.net/pvkovalev/4PACy/

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

    Update October 2016:

    CDN link for CKEditor has been changed, so I updated jsfiddle

提交回复
热议问题