繁体   English   中英

使用p:commandButton和p:dialog时出现Javascript错误

[英]Getting Javascript error while using p:commandButton and p:dialog

当我点击p:commandButton来显示ap:dialog时,我收到一个javacript错误。

请找到以下错误:

Message: Object doesn't support this property or method
Line: 1
Char: 169
Code: 0
URI: http://localhost:8080/idm/javax.faces.resource/dialog/dialog.js.xhtml?     ln=primefaces&v=2.2.1

Message: Object doesn't support this property or method
 Line: 1
 Char: 133
 Code: 0
 URI: http://localhost:8080/idm/javax.faces.resource/button/button.js.xhtml?ln=primefaces&v=2.2.1

这是代码块:

     <ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui" 
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<p:commandButton value="save"  onclick="dlg1.show();" ></p:commandButton>
     <p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1">  
  <h:outputText value="Resistance to PrimeFaces is futile!" />  
</p:dialog>
      </ui:composition>

所有其他primefaces组件工作正常。

任何帮助,将不胜感激。

是的,我们正在使用另一个jQuery副本

去掉它。 PrimeFaces作为一个基于jQuery / jQuery UI的JSF组件库已经自动包含其捆绑的jQuery文件以及其他对话框组件。 jQuery的多个副本只会相互冲突,导致像你所面临的JS错误。

如果您打算在不一定使用自动包含PrimeFaces捆绑的jQuery文件的PrimeFaces组件的页面上使用jQuery,那么将此行添加到<h:head>

<h:outputScript library="primefaces" name="jquery/jquery.js" />

这样,PrimeFaces捆绑的jQuery文件总是包含在内,如果某些PrimeFaces组件碰巧需要它,PrimeFaces将不会自动包含重复的jQuery文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM