-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
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.