Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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()
}
})
};
@ericsala

This comment has been minimized.

Show comment
Hide comment
@ericsala

ericsala Feb 25, 2015

It will work for bootstrap 2.3.2 ?
Thank you!

ericsala commented Feb 25, 2015

It will work for bootstrap 2.3.2 ?
Thank you!

@skilef

This comment has been minimized.

Show comment
Hide comment
@skilef

skilef Mar 29, 2015

Thank's !!!
Saved my day

skilef commented Mar 29, 2015

Thank's !!!
Saved my day

@AdnaneX

This comment has been minimized.

Show comment
Hide comment
@AdnaneX

AdnaneX Dec 17, 2015

sir how can i use for modal semantic ui http://semantic-ui.com/modules/modal.html

AdnaneX commented Dec 17, 2015

sir how can i use for modal semantic ui http://semantic-ui.com/modules/modal.html

@AlexPiuPiu

This comment has been minimized.

Show comment
Hide comment
@AlexPiuPiu

AlexPiuPiu Mar 7, 2016

thank you so much!!!
Bootstrap v3.3.4 use: modal_this.$element.blur(), it works well in IE11

AlexPiuPiu commented Mar 7, 2016

thank you so much!!!
Bootstrap v3.3.4 use: modal_this.$element.blur(), it works well in IE11

@dangdinhtu2014

This comment has been minimized.

Show comment
Hide comment
@dangdinhtu2014

dangdinhtu2014 Jun 30, 2016

It not work with textarea as plugin code for ckeditor

dangdinhtu2014 commented Jun 30, 2016

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