もし私がCKエディターBootstrapテンプレートに基づいたHTMLページにプラグインを挿入するとうまく機能しますが、次のようにBootstrapモーダルにエディターを挿入すると
<!-- Modal -->
<div class="modal fade" id="modalAddBrand" tabindex="-1" role="dialog" aria labelledby="modalAddBrandLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="modalAddBrandLabel">Add brand</h4>
</div>
<div class="modal-body">
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea> <script>
CKEDITOR.replace('editor1');
</script>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="AddBrandButton" type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
エディターは動作しますが、エディターのポップアップ ウィンドウ上のすべてのフォーム コントロールが無効になっています。たとえば、リンクや画像を追加しようとすると、入力が無効になっているため、URL や説明を挿入できません。
この問題の回避策はありますか?
これはフィドルの例です:http://jsfiddle.net/7zDay/
ベストアンサー1
これは役に立つはずだhttp://jsfiddle.net/pvkovalev/4PACy/
$.fn.modal.Constructor.prototype.enforceFocus = function () {
var $modalElement = this.$element;
$(document).on('focusin.modal', function (e) {
var $parent = $(e.target.parentNode);
if ($modalElement[0] !== e.target && !$modalElement.has(e.target).length
// add whatever conditions you need here:
&&
!$parent.hasClass('cke_dialog_ui_input_select') && !$parent.hasClass('cke_dialog_ui_input_text')) {
$modalElement.focus()
}
})
};
2016 年 10 月更新:
CKEditorのCDNリンクが変更されたので、jsfiddleを更新しました