optimus.prime wrote:To implement stacking to deal with multiple overlay components(dialog, confirmDialog, autoComplete, selectOneMenu...) on page.
An overlay should move to top dynamically so a static z-index cannot be used.
I include the dialogs dinamically using ui:include, so I need to give max z-index value to the last dialog inserted...
From serverside I send requestContext.execute("moveDialogOnTop(<params>)");
Code: Select all
<p:outputPanel id="window1ContainerPanel" layout="block"
binding="#{win1EBB.container}">
<ui:include src="#{win1EBB.include}" />
</p:outputPanel>
<p:outputPanel id="window2ContainerPanel" layout="block"
binding="#{win2EBB.container}">
<ui:include src="#{win2EBB.include}" />
</p:outputPanel>
<script language="JavaScript">
function moveDialogOnTop(containers, dialogToMoveOnTop) {
var maxZIndex = 0;
var zIndex = 0;
for each (var container in containers){
var str = String(container);
if(str.indexOf('form') == 0){
var panelContainer = document.getElementById(container);
var divs = panelContainer.getElementsByTagName('div');
var dialog = divs[0]
if(dialog != null){
zIndex = dialog.style.zIndex;
if(zIndex > maxZIndex){
maxZIndex = zIndex;
}
}
}
}
var num = new Number(maxZIndex);
document.getElementById(dialogToMoveOnTop).style.zIndex = num+1;
}
</script>
After "moveDialogOnTop" the z-index of the dialog become fixed: it doesn't change when I dragg the dialog...
Why the instruction document.getElementById(dialogToMoveOnTop).style.zIndex makes the z-index static/fixed inside the element.style?