CKEditor issue with Bootstrap modal

☆樱花仙子☆ 提交于 2019-12-01 20:31:38

Try the solution described in this guide:

$.fn.modal.Constructor.prototype.enforceFocus = function() {
    $( document )
        .off( 'focusin.bs.modal' ) // guard against infinite focus loop
        .on( 'focusin.bs.modal', $.proxy( function( e ) {
            if (
                this.$element[ 0 ] !== e.target && !this.$element.has( e.target ).length
                // CKEditor compatibility fix start.
                && !$( e.target ).closest( '.cke_dialog, .cke' ).length
                // CKEditor compatibility fix end.
            ) {
                this.$element.trigger( 'focus' );
            }
        }, this ) );
};

Demo: http://jsfiddle.net/7zDay/17/. Works fine for me. AFAICS this is a more general fix.

It's so simple and doesn't create any script conflict.    
<!DOCTYPE html>
    <html>

    <head>
        <meta charset="utf-8">
        <meta name="robots" content="noindex, nofollow">
        <title>Classic editor with default styles</title>
        <script src="http://cdn.ckeditor.com/4.6.2/standard-all/ckeditor.js"></script>
    </head>

    <body>

        <textarea cols="80" id="editor1" name="editor1" rows="10" >&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;
        </textarea>

        <script>
            CKEDITOR.replace( 'editor1', {
                height: 260,
                width: 700,
            } );
        </script>
    </body>

    </html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!