对话框不会关闭原子

编程入门 行业动态 更新时间:2024-10-06 23:25:00
本文介绍了对话框不会关闭原子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在我的一个页面上有一个对话框。它开好了它工作正常,如果您使用页面上的按钮,它关闭。但是,如果您尝试使用对话框中的x,则不会关闭。我相信这与我在对话框上有一个输入字段的事实有关,但我不确定。我很抱歉,如果这是一个骗子,我找不到类似的职位。

< p:commandButton action =#{phoneListBean.debugger} value =Merge Unqiueonclick = mdlg.show(); update =:pmsg,:createNewPanel,:listform/> < p:dialog id =mdialogheader =合并UnqiuewidgetVar =mdlg appendToBody =true> < h:form id =mform> < h:panelGrid columns =2cellpadding =5id =m> < h:outputLabel for =listNamevalue =输入列表名称:/> < p:inputText value =#{phoneListBean.mergeList.name}id =listName/> < p:commandButton action =#{phoneListBean.mergeUnique} value =Merge Unqiueupdate =:pmsg,:listform的onclick = mdlg.hide(); /> < / h:panelGrid> < / h:form> < / p:dialog>

提前感谢帮助。

解决方案

您的问题是您不想使用 onclick 属性用于显示和隐藏对话框的Primefaces按钮。点击事件可能无法在回发之前调用,因为这些按钮不是启用Ajax。

相反,您应该使用 oncomplete 属性。这将通知JavaScript事件仅在服务器回发发生后执行,这意味着 show()将显示已更新的对话框内容, hide )仅在服务器端执行完成后才会发生。

I have a dialog on one of my pages. It opens fine. It works fine if you use the button on the page, it closes. However, if you try and "x" out of the dialog it will not close. I believe it is related to the fact that I have an input field on the dialog, but I am not sure. I apologize if this is a dupe, I could not find a similar post.

<p:commandButton action="#{phoneListBean.debugger}" value="Merge Unqiue" onclick="mdlg.show();" update=":pmsg, :createNewPanel, :listform" /> <p:dialog id="mdialog" header="Merge Unqiue" widgetVar="mdlg" appendToBody="true"> <h:form id="mform"> <h:panelGrid columns="2" cellpadding="5" id="m"> <h:outputLabel for="listName" value="Enter the List Name:" /> <p:inputText value="#{phoneListBean.mergeList.name}" id="listName" /> <p:commandButton action="#{phoneListBean.mergeUnique}" value="Merge Unqiue" update=":pmsg, :listform" onclick="mdlg.hide();" /> </h:panelGrid> </h:form> </p:dialog>

Thanks in advance for the help.

解决方案

Your problem is that you don't want to use the onclick attribute with Primefaces buttons for displaying and hiding the dialogs. The click event may not get invoked before the postback because these buttons are not Ajax enabled.

Instead you should use oncomplete attribute. This will notify the Javascript event to execute only after the server postback has occurred, meaning that show() will display already updated dialog contents, and hide() will occur only after the server side execution has finished.

更多推荐

对话框不会关闭原子

本文发布于:2023-11-28 04:17:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640924.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   原子

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!