Summernote模态锁定在纯Bootstrap模态中

deyfvvtc  于 12个月前  发布在  Bootstrap
关注(0)|答案(7)|浏览(176)

有没有一种已知的方法可以让summernote模态从bootstrap模态中爆发出来?
我有一个普通的modal,里面有一个summernote元素,没有什么特别的。
当我使用summernote功能时,如果我在bootstrap模式中使用summernote,这就是我得到的:

JS:

$('#dropper').on( "show.bs.modal", function() {
    $('#dropping').summernote({
        height: 300
    });
})

HTML:

<div id="dropper" class="modal fade" tabindex="-1" data-backdrop="static" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div id="dropping">text...</div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default pull-left">
                    <span class='fa fa-paperclip '></span>
                    Attach Digital Assets
                </button>
                <div class="btn-group">
                    <button type="button" class="btn btn-default opacity75" class="close" data-dismiss="modal">
                        &times; Cancel
                    </button>
                    <button type="button" class="btn btn-warning" href="javascript:postDrop()">
                        Post Status Update
                        <span class='fa fa-bullhorn '></span>
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

完整Bootply:http://bootply.com/113808

vltsax25

vltsax251#

在summernote 0.6.13+中,尝试使用对话框InBody-Parameter初始化:

$('#dropping').summernote({
    dialogsInBody: true
});
toe95027

toe950272#

我也遇到了同样的问题,由于时间紧迫,我想出了这个解决方案(本质上是把summernote的模态转换成“正常”的div,而不是显式的模态,即。删除类'modal'):-
summernote.js(编辑完整文件):-
查找以下行并更改为:-

(2922 approx.) var tplImageDialog = function () {
    return '<div class="note-image-dialog" aria-hidden="false" style="z-index:9999">' +
             '<div class="modal-dialog">' +
               '<div class="modal-content">' +
                 '<div class="modal-header">' +
                   '<button type="button" class="close-summernote-dialog" aria-hidden="true" tabindex="-1">&times;</button>' +

(2946 approx.) var tplLinkDialog = function () {
    return '<div class="note-link-dialog" aria-hidden="false" style="z-index:9999">' +
             '<div class="modal-dialog">' +
               '<div class="modal-content">' +
                 '<div class="modal-header">' +
                   '<button type="button" class="close-summernote-dialog" aria-hidden="true" tabindex="-1">&times;</button>' +

(2981 approx.) var tplVideoDialog = function () {
    return '<div class="note-video-dialog" aria-hidden="false" style="z-index:9999">' +
             '<div class="modal-dialog">' +
               '<div class="modal-content">' +
                 '<div class="modal-header">' +
                   '<button type="button" class="close-summernote-dialog" aria-hidden="true" tabindex="-1">&times;</button>' +

然后添加一些自定义的jQuery代码到调用summernote的地方:

$("button.close-summernote-dialog").click(function(){

   $('.note-image-dialog').modal('hide');
   $('.note-link-dialog').modal('hide');
   $('.note-video-dialog').modal('hide');
   $('.note-help-dialog').modal('hide');

})//end of $("button.close-summernote-dialog").click(function(){

最后添加一些css:-

.close-summernote-dialog {float: right ; font-size: 21px ; font-weight: bold ; line-height: 1 ; color: #000000 ; text-shadow: 0 1px 0 #ffffff ; opacity: 0.2 ; filter: alpha(opacity=20);}
.close-summernote-dialog:hover,
.close-summernote-dialog:focus {color: #000000 ; text-decoration: none ; cursor: pointer ; opacity: 0.5 ; filter: alpha(opacity=50);}
button.close-summernote-dialog {padding: 0 ; cursor: pointer ; background: transparent ; border: 0 ; -webkit-appearance: none;}

希望能帮上忙?

hsvhsicv

hsvhsicv3#

我以前遇到过同样的问题,并通过以下步骤解决了它们:
首先,确保在创建summernote示例时指定dialogsInBody: true
其次,为了支持summernote中使用的嵌套多引导模式对话框,并支持显示工具提示和弹出框,请在全局位置注册以下事件处理程序:

$(document).on("show.bs.modal", '.modal', function (event) {
    console.log("Global show.bs.modal fire");
    var zIndex = 100000 + (10 * $(".modal:visible").length);
    $(this).css("z-index", zIndex);
    setTimeout(function () {
        $(".modal-backdrop").not(".modal-stack").first().css("z-index", zIndex - 1).addClass("modal-stack");
    }, 0);
}).on("hidden.bs.modal", '.modal', function (event) {
    console.log("Global hidden.bs.modal fire");
    $(".modal:visible").length && $("body").addClass("modal-open");
});
$(document).on('inserted.bs.tooltip', function (event) {
    console.log("Global show.bs.tooltip fire");
    var zIndex = 100000 + (10 * $(".modal:visible").length);
    var tooltipId = $(event.target).attr("aria-describedby");
    $("#" + tooltipId).css("z-index", zIndex);
});
$(document).on('inserted.bs.popover', function (event) {
    console.log("Global inserted.bs.popover fire");
    var zIndex = 100000 + (10 * $(".modal:visible").length);
    var popoverId = $(event.target).attr("aria-describedby");
    $("#" + popoverId).css("z-index", zIndex);
});

前面的代码将支持嵌套的引导模态对话框和工具提示和弹出框。下图显示了结果:

您可以调整上述z索引为您所需的值。
以下发布描述了这些代码:
https://github.com/summernote/summernote/issues/2644https://github.com/summernote/summernote/issues/2457

wwodge7n

wwodge7n4#

因为你在另一个模态中打开了一个模态。这不是推荐的做法
http://getbootstrap.com/javascript/#modals

nwlqm0z1

nwlqm0z15#

我也遇到了这个问题,伙计们,另一个问题出现了。当summernote模式关闭时,父模式滚动被破坏。这就是解决办法。我只是在summernote.js的第2020行添加了这个$(“body”).addClass(“modal-open”)。在“hideDialog”方法中。
enter image description here

ktca8awb

ktca8awb6#

我在bootstrap modals中使用summernote时遇到了同样的问题。当我想添加图片/视频/链接时,summernote模态会出现在父模态的后面。这就是我解决问题的方式。

$('.summernote').summernote({
    height: 300,
    dialogsInBody: true
});

$('.note-image-dialog, .note-link-dialog, .note-video-dialog, .note-help-dialog').on('show.bs.modal', function() {
    $(this).detach().appendTo('body');
});

$('.note-image-dialog, .note-link-dialog, .note-video-dialog, .note-help-dialog').on('hide.bs.modal', function() {
    $(this).detach().appendTo('.note-dialog');
});
gywdnpxw

gywdnpxw7#

我有同样的错误,这是我如何解决它,它的工作正常

$('.editor-Answer').summernote(
    {
        inheritPlaceholder: true,
        dialogsInBody: true
    }
);

$(document).on("hidden.bs.modal", '.modal', function () {
    $(".modal:visible").length && $("body").addClass("modal-open");
});

相关问题