如果我使用CKEditor http://cksource.com/ckeditor基于 Bootstrap 模板的 HTML 页面中的插件,效果很好,但是如果我像这样在 Bootstrap Modal 上插入编辑器
<!-- 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/ http://jsfiddle.net/7zDay/
这应该有帮助http://jsfiddle.net/pvkovalev/4PACy/ 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)