Skip to content

Bug with Stacking order #93

@mattbryson

Description

@mattbryson

great, plugin, saved me hours of work! But found a edge case issue with the stacking. The stacking works fine if you create and show the modals in sequential order.

However, in some cases you can create the modal but not show it, and then later programatically show it with show hide methods

$('#mymodal').modal({show:false, otherProperty:true});

later..

$('#mymodal').modal('show');

In this case, the order the modals are created may not be the same as the order that they are shown, and then the stacking falls down, as the stacking order is based on the ModalManager.stack array, wich indexes the modals at the time of creation.

My work around for this (which may not be the best solution, hence im not pushing any changes) is to ignore the stack order for the index, and instead calculate a modal index based on the visibility of other modals.

I overrode the getIndexOfModal method with this patch

 $.fn.modalmanager.Constructor.prototype.getIndexOfModal=function (modal) {
       var index=0;
        for (var i = 0; i < this.stack.length; i++){
            if(this.stack[i].isShown) {
               index++;
            }
        }
        return index;      
    };

It works for my requirements, but not sure if this affects other parts of the plugin.

Happy to add this logic to the main lib and make a pull request if your happy with it.

Cheers

m.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions