[英]jsf PrimeFaces how to close modal form
I created a modal form. 我创建了一个模式表格。 while the submit button works fine:
虽然提交按钮可以正常工作:
<p:commandButton ajax="false" value="save" action="#{editErReferencesFormWebBean.submit}" />
I don't know how to create a cancel button that just closes the dialog. 我不知道如何创建仅关闭对话框的取消按钮。 I don't want to call the server for it.
我不想为此打电话给服务器。 Is there a simple way to just clos the dialog (and discard all inputs)?
有没有简单的方法可以关闭对话框(并丢弃所有输入)?
Reading Primefaces documentation: 阅读Primefaces文档:
<p:dialog widgetVar="modal" modal="true" closable="false">
<!-- Modal content -->
<h:form id="form">
<p:commandButton value="Cancel" onclick="PF('modal').hide();$('#form').trigger('reset');" type="button" />
</h:form>
</p:dialog>
Also, you could set closable
attribute to true
for displaying X
icon which closes the dialog. 另外,您可以将
closable
属性设置为true
以显示关闭对话框的X
图标。
Try this: 尝试这个:
<h:form id="form">
<h:panelGrid columns="1" cellpadding="5">
<p:commandButton value="Modal" type="button" onclick="PF('dlg').show();" />
</h:panelGrid>
<p:dialog header="Modal Dialog" id="myDialog" widgetVar="dlg" modal="true" height="100">
<h:outputText value="This is a Modal Dialog." />
<p:inputText/>
<button id="myButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" onclick="$('#form\\:myDialog').hide(); $('#form\\:myDialog_modal').remove();$('#form').trigger('reset');">
<span class="ui-button-text ui-c">
My Button
</span>
</button>
</p:dialog>
</h:form>
Regards. 问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.