“primefaces”对话框在单击按钮时不显示
我有primefaces版本“primefaces”对话框在单击按钮时不显示,primefaces,Primefaces,我有primefaces版本6.0,我遇到了一个对话框没有出现的问题 这是按钮 <p:commandButton id="newRequestButton" class="btn btn-lg btn-primary" value="New Request" update=":newRequestForm:newRequestDialog" oncom
6.0
,我遇到了一个对话框没有出现的问题
这是按钮
<p:commandButton id="newRequestButton"
class="btn btn-lg btn-primary"
value="New Request"
update=":newRequestForm:newRequestDialog"
oncomplete="PF('newRequest').show()" />
这是对话
<p:dialog header="Request Definitions" widgetVar="newRequest"
resizable="true" width="600" showEffect="explode"
hideEffect="explode" modal="true" height="300"
class="modal-dialog">
<h:form id='newRequestForm'>
<h:panelGrid id="newRequestDialog" columns="1" cellpadding="4"
class="modal-content">
</h:panelGrid>
</h:form>
</p:dialog>
有什么问题吗。我已经遵循了一些类似的答案,但没有结果
编辑:
对于
表单
和激活它们的命令按钮
来说,对话框
应该放在哪里?您需要将commandButton和对话框放在h:form标记中,带有类似“form”的id属性,然后在commandButton的更新属性中,首先写上“form”(包含按钮和对话框的h:form的id属性值)。请尝试以下代码:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
<h:head>
</h:head>
<h:body>
<h:form id="form">
<p:commandButton id="newRequestButton"
class="btn btn-lg btn-primary"
value="New Request"
update=":form:newRequestDialog"
oncomplete="PF('newRequest').show()" />
<p:dialog header="Request Definitions" widgetVar="newRequest"
resizable="true" width="600" showEffect="explode"
hideEffect="explode" modal="true" height="300"
class="modal-dialog">
<p:outputPanel id="newRequestDialog" style="text-align:center;">
<p:panelGrid columns="1" class="modal-content">
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</h:body>
</html>
问题是我同时包含了引导jquery和primefaces绑定的jquery。禁用引导jquery有效。您在日志记录中调查了什么?浏览器控制台?您是否尝试更新对话框内容,然后显示它而不是更新对话框?@Kukeltje,您可以看到我正在更新h:panelGrid代码>其中包含对话框的内容对不起,误读了…:-(当窗体是模态的并且有一个“appendTo”的body时,它应该在对话框中(请参阅PF文档。与commandButton相关的位置实际上并不相关。没有理由认为这不起作用,除非由于commandButton根本不起作用而没有调用服务器,这可以通过用普通javascript警报替换“show”来测试。@Kukeltje即使使用appendTo
也不会发生任何事情,为什么“commandButtons”不起作用?我没有说你应该使用appendTo,我说当它被使用时,你需要表单在对话框中。为什么commandButtons不起作用,嗯……我的代码实际上是类似的,但是表单没有嵌套。但这仍然不起作用。我使用的是chrome。打开了开发者选项并在控制台上单击时,我没有收到任何错误消息或任何消息。上面的代码在primefaces 5.0中运行良好。现在请尝试上面编辑的代码,它不包含嵌套表单,并且单击CommandButton时对话框也会打开。出现了相同的问题。问题是什么?对话框没有打开吗?或者panelGrid没有更新吗n您很可能在JS控制台中出错…下次请创建一个…现在没有任何导致您的问题的内容可见。