将Primefaces对话框定位在命令链接下方

时间:2011-07-03 11:31:35

标签: jsf dialog primefaces

我正在尝试使用以下语法将我的对话框放在命令链接下面。但是它不起作用,而且每当我向上或向下滚动页面时,对话位置都在变化。感谢任何帮助。

<p:dialog context="'mainForm:commandLinkA','tl','br'" widgetVar="TreeDlg" header="Select " draggable="false">

谢谢和问候, 连珠

1 个答案:

答案 0 :(得分:1)

我设法使用jquery解决了这个问题。我在单击命令链接时调用以下jquery函数,并向其传递要打开的对话框ID和源命令链接ID。

function adjustPositionandOpenDialog(currentDialog,commandSource) { 
    $(currentDialog).dialog( 'open' );      
    var myDialogX = jQuery(commandSource).position().left+10;
    var myDialogY = jQuery(commandSource).position().top - ( jQuery(document).scrollTop() + jQuery('.ui-dialog').outerHeight() )+142;
    jQuery(currentDialog).dialog( 'option', 'position', [myDialogX, myDialogY] );
}

谢谢,
连珠