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() | |
} | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Me too:(