我有一个表单,当单击某些操作时,它会通过 Ajax+Rendered“增长”。问题是当表单增长时我的 p:confirmDialog 没有垂直居中。当处于“正常大小”时,对话框正确居中。
我已经尝试过:
- 删除或添加“appendToBody”属性
- 更改页面中声明的位置(h:form 之前和之后)
- 覆盖 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>
最佳答案
您是否按百分比覆盖了对话框的 TOP 属性?如果没有请覆盖对话框div的css。
#dialogBoxId{
top: 50% !important;
left:50% !important;
}
关于java - Primefaces 确认对话框在使用 ajax 更新的表单中未垂直居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26740262/