Imagine a modal dialog created inside an ASP.NET UpdatePanel:
modal: true,
autoOpen: false,
appendTo: myUpdatePanel
On every postback I'll re-create the dialog, then an openingCondition over a field ($('#popupState').val() == "1") makes to open (or to close) the dialog.
Let see what happens inside jQueryUI: 1. popup created but not visible: $.ui.dialog.overlayInstances == 0 2. (openingCondition == false) and the dialog stay closed: $.ui.dialog.overlayInstances == 0 3. a click opens the dialog: $.ui.dialog.overlayInstances == 1 4. a PostBack event generated inside the dialog raises a partial reload of myUpdatePanel --reload-- 1. popup created but not visible: $.ui.dialog.overlayInstances == 1 (!) 2. (openingCondition == true) the dialog will open: $.ui.dialog.overlayInstances == 2 (!) 4. a PostBack inside the dialog raises a reload --reload-- 1. popup created but not visible: $.ui.dialog.overlayInstances == 2 (!!) 2. (openingCondition == true) the dialog will open: $.ui.dialog.overlayInstances == 3 (!!) 4. a PostBack inside the dialog raises a reload
and so on... I saw that $.ui.dialog.overlayInstances != $(".ui-widget-overlay").length ... is this a bug?