2014-11-04 54 views
1

我有一個通過Ajax +「增長」的表單,當點擊某些操作時呈現。問題是,當表單增長時,我的p:confirmDialog不是垂直居中。當處於「正常大小」時,對話框正確居中。Primefaces ConfirmDialog不是以ajax更新的形式垂直居中

我已經嘗試:

  • 刪除或添加「appendToBody」屬性
  • 更改申報的在頁面的位置(前,後H:形式)
  • 覆蓋「頂」在CSS

是從Primefaces(目前使用v4)的問題還是我做錯了什麼?由於我使用了大量的「渲染」屬性,我應該「重新渲染」對話框嗎?

下面是我的代碼片段。

<h:form id="myForm">    
    <p:fieldset legend="Hello"> 
     <!-- lots of things here --> 
    </p:fieldset> 
    <p:spacer height="20px" /> 
    <p:fieldset legend="Dashboard" 
     id="thisOneMakesTheFormGrows" 
     rendered="#{bean.include or bean.edit}"> 
     <!-- this one has lots of items, making the page grow when the 'rendered' attribute is true --> 
    </p:fieldset> 
</h:form>   

<p:confirmDialog global="true" 
    id="meuConfirmDlg" 
    appendToBody="true" 
    showEffect="fade" 
    width="500px" 
    hideEffect="fade" 
    widgetVar="confirmDlg" 
    closable="false"> 
    <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" /> 
    <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" /> 
</p:confirmDialog> 

回答

1

你是否用百分比覆蓋了對話框的TOP屬性?如果不是,請覆蓋對話框div的css。

#dialogBoxId{ 
top: 50% !important; 
left:50% !important; 
} 
+0

就是這樣!只需要移除「left」屬性,因爲它在屏幕的右側顯示了對話框。 – 2014-11-27 10:16:24