0

我有一个这样的primefaces对话框:

<p:dialog widgetVar="dlg" width="320" height="220" modal="false" closable="false" showHeader="false" resizable="false" position="right,top">

如果我单击页面中的某个元素,我想将此对话框更改为模态。是否有用于此的客户端 API?

试过了

onclick="dlg.setModal(true);"

没有成功。方法 setModal() 不存在。是否可以在不往返服务器的情况下以这种方式更改对话框?

4

2 回答 2

0

Do you use Firefox with Firebug or some other browser / web developer tool that can show you the DOM element dlg?

There you can find that dlg has the methods show() and hide(), as well as enableModality()and disableModality(). These are (almost) what you want.

Unfortunately, enable... and disable don't (as one might think) set an option that makes the dialog become modal when shown. Rather they show or hide the "blackout" div. So when you want a dynamically modal dialog, instead of calling dlg.show() via Javascript, call dlg.enableModality(); dlg.show(), and vice versa for hiding.

Edit:

There is also the property dlg.cfg which contains some settings. It appears that if you simply set dlg.cfg.modal=true (whether that setting exists at the time or not), then the next time dlg is shown, it's modal (but, unlike setting it in your xhtml, it will still be draggable and resizable).

于 2013-06-26T09:04:27.370 回答
0

你有这个(模态)的属性,现在它设置为假 madal="true"

于 2013-02-15T10:04:17.717 回答