Javascript modal=true 的 Primefaces 对话框无法正常工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6410426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 21:36:19  来源:igfitidea点击:

Primefaces dialog with modal=true not working properly

javascriptcssjsfprimefaces

提问by Rajat Gupta

I am unable to achieve a (primefaces)dialogbox with attribute modal=true. It works correctly with modal=false, but when I try to set modal=true, even the dialog box overlay becomes inactive.

我无法实现dialog具有属性的(素数)框modal=true。它在 modal=false 的情况下正常工作,但是当我尝试设置时modal=true,甚至对话框覆盖也变得不活动。

How can I make it work properly ?

我怎样才能让它正常工作?

采纳答案by maple_shaft

Per the Primefaces Guide 2.2 on the Dialog section:

根据对话部分的 Primefaces Guide 2.2:

appendToBody FALSE Boolean Appends dialog as a child of document body.

appendToBody FALSE Boolean 将对话框附加为文档正文的子级。

When using the Primefaces dialog utilize the appendToBody attribute to enable the dialog overlay to be found. The Primefaces dialog is based on the YUI dialog component which has a similar issue for modal dialog overlays.

使用 Primefaces 对话框时,请利用 appendToBody 属性来启用对话框覆盖。Primefaces 对话框基于 YUI 对话框组件,该组件在模态对话框叠加方面具有类似的问题。

Manipulating the dialog overlay will involve overriding the CSS class of the overlay and specifying your own opacity.

操作对话框覆盖将涉及覆盖覆盖的 CSS 类并指定您自己的不透明度。

回答by Abhishek Dhote

With Primefaces 5 appendTo="@(body)"fixed the issue for me.

Primefaces 5appendTo="@(body)"为我解决了这个问题。

回答by Corneil du Plessis

I have also struggled with strange behaviour until I moved the p:dialoginto a separate h:format which point the data in the dialog matched the row from the dataTable but the overlay was not hiding.

我也一直在与奇怪的行为作斗争,直到我将其p:dialog移到一个单独的h:form位置,此时对话框中的数据与 dataTable 中的行匹配,但覆盖层没有隐藏。

appendToBody=truesolved the problem with the overlay. I still need to test dialogs with inputs and actions.

appendToBody=true解决了覆盖的问题。我仍然需要使用输入和操作来测试对话框。

回答by Gunjan Kalra

appendToBody=true causes the problems associated with nested forms - the input texts values as entered at the dialog are ignore and ajax requests do not go through until the dialog gets its own non-nested form. Even without modal=true the appentToBody=true causes this behavior.

appendToBody=true 会导致与嵌套表单相关的问题 - 在对话框中输入的输入文本值被忽略,并且在对话框获得自己的非嵌套表单之前不会通过 ajax 请求。即使没有 modal=true appendToBody=true 也会导致这种行为。