簡體   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