Skip to content

Instantly share code, notes, and snippets.

@kaddopur
Created April 5, 2014 18:48
Show Gist options
  • Save kaddopur/9996231 to your computer and use it in GitHub Desktop.
Save kaddopur/9996231 to your computer and use it in GitHub Desktop.
// bootstrap-ckeditor-modal-fix.js
// hack to fix ckeditor/bootstrap compatiability bug when ckeditor appears in a bootstrap modal dialog
//
// Include this AFTER both bootstrap and ckeditor are loaded.
// From: http://stackoverflow.com/questions/14420300/bootstrap-with-ckeditor-equals-problems
// Author: http://stackoverflow.com/users/185839/aaron
$.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()
}
})
};
@dangdinhtu2014
Copy link

It not work with textarea as plugin code for ckeditor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment