nakupanda / bootstrap3-dialog

Make use of Twitter Bootstrap's modal more monkey-friendly.
https://nakupanda.github.io/bootstrap3-dialog/
1.89k stars 664 forks source link

Opening multiple dialogs #287

Open Libig opened 8 years ago

Libig commented 8 years ago

Hi, I found this project which might be good for me.

Is it possible to have multiple dialogs all being accessible (closable) on their own with only one overlay gray background?

Thanks!

nakupanda commented 8 years ago

I think it can't be done like that easily. By saying 'easily' here I mean it's also possible but it's just difficult to do it.

mtorak commented 8 years ago

Hi there, i also have a similar requirement which is multiple non-modal draggable dialogs. All modals should be accessible and shouldn't block the page. Do you have a solution / recommendation for this case? Thank you

elsuenog commented 8 years ago

Hi, I had to do something similar to this. Originally I wanted two active modals being active(accessible at the same time), but seeing as I had a short period of time to do this; I just added buttons to switch between modals. It's not mind blowing but it works for what I need it to do, maybe later when I have free time I will dive deeper to make it simpler.

`        var instance1 = new BootstrapDialog({
            type: BootstrapDialog.TYPE_INFO,
            title: "Are you sure?",
            cssClass: 'test',
            message: $('#tableResults'),
            draggable: true,
            closeByBackdrop: false,
            buttons: [{
                icon: 'glyphicon glyphicon-menu-right',
                cssClass: "btn-xs btn-primary forward",
                action: function (dialogRef) {
                    $('.forward').css({ "display": "none" });
                    $('.back').css({ "display": "initial" });
                    dialogRef.setClosable(true);
                    $('.cancelButton').removeAttr('disabled');
                    $('.submit').removeAttr('disabled');
                    $('.test1').css("z-index", 1051);
                    $('.test').css("z-index", 1050);
                }
            }, {
                label: "Cancel",
                cssClass: "btn-default cancelButton",
                action: function (dialogRef) {
                    dialogRef.close();
                    instance2.close();
                }
            }, {
                label: "Submit",
                cssClass: "btn-primary submit",
                action: function (dialogRef) {
                    instance2.open();
                }
            }]
        });
        instance1.open();
            var instance2 = new BootstrapDialog({
                type: BootstrapDialog.TYPE_INFO,
                title: "This is instance 2?",
                message: "Hello world!",
                draggable: true,
                autodestroy: false,
                cssClass: 'test1',
                onshown: function (dialog) {
                    if (dialog.$modal.prev(".modal-backdrop").length===1)
                        dialog.$modal.prev(".modal-backdrop").css("z-index", 1040);
                    else
                        dialog.$modal.next(".modal-backdrop").css("z-index", 1040);
                    dialog.$modal.css("z-index", 1051);

                },
                closeByBackdrop: false,
                buttons: [{
                    icon: 'glyphicon glyphicon-menu-left',
                    cssClass: "btn-xs btn-primary back",
                    action: function (dialogRef) {
                        $('.forward').css({ "display": "initial" });
                        $('.back').css({ "display": "none" });
                        $('.cancelButton').attr('disabled', 'disabled');
                        $('.submit').attr('disabled', 'disabled');
                        instance1.setClosable(false);
                        var top = $(".test1 .modal-dialog").css("top");
                        $('.test1').css("z-index", 1050);
                        $('.test').css("z-index", 1051);
                        $(".test .modal-dialog").css({"top":top});
                    }
                }, {
                    label: "Cancel",
                    action: function (dialogRef) {
                        dialogRef.close();
                    }
                }, {
                    label: "Submit",
                    cssClass: "btn-primary",
                    action: function (dialogRef) {
                        $('.alert').css({ "display": "inherit" });
                        dialogRef.close();
                    }
                }]
            });`