PrimeFaces Dialog + appendToBody=true not working

谁说胖子不能爱 提交于 2019-12-05 18:58:07

I know this is a old question, but I was having the same problem with Primefaces 5. The solution was simple, I've included the attribute appendTo="@(body)" in tag.

<p:dialog header="Title" widgetVar="dlg" modal="true" appendTo="@(body)">
  <h:outputText value="Dialog text..." />
  <p:commandButton value="Ok" onclick="PF('dlg').close()" />
</p:dialog>

Perhaps the answer is not to use appendToBody. Do you really need it?

One of the common reasons for using appendToBody is to avoid error resulting from putting modal dialogs inside layouts. This workaround, as you've already noted, results in "unpredictable behaviour". The better way would be just to place the dialog outside the layout.

For more details please see:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!