Created
January 7, 2016 19:05
-
-
Save james2doyle/65d06029bfd128dd5ecc to your computer and use it in GitHub Desktop.
A patch for using CKEditor inside a bootstrap modal. Fixed the issue with fields not focusing in the modal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bootstrap-ckeditor-fix.js | |
// hack to fix ckeditor/bootstrap compatiability bug when ckeditor appears in a bootstrap modal dialog | |
// | |
// Include this file AFTER both jQuery and bootstrap are loaded. | |
// http://ckeditor.com/comment/127719#comment-127719 | |
$.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 | |
&& !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') | |
&& !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) { | |
modal_this.$element.focus() | |
} | |
}) | |
}; |
not work for me
Me too:(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this code, but it seems to be causing the same issue.
Its just the dropdowns inside the CKEditor whch are causing the issue within Bootstrap modals.
Sequence of loading the scripts are as follows:
@Scripts.Render("
/bundles/jquery")/bundles/jqueryval")@Scripts.Render("
@Scripts.Render("
/bundles/bootstrap")/bundles/ckeditor")@Scripts.Render("
@Scripts.Render("~/bundles/ckeditorBootstrapFix")
Where bundles are
bundles.Add(new ScriptBundle("
/bundles/jquery").Include(/Scripts/jquery-{version}.js","
"~/Scripts/jquery-ui-{version}.js"));