【发布时间】:2015-08-31 16:08:26
【问题描述】:
我的 JSF 页面中有很多标签。我想在其中一种表单中使用 javascript 单击p:commandButton。但它不起作用。当我使用chrome调试它时,它提示 The p:commandButton can't be found ,也就是说 $("#templetFile\:editButton") 为空,为什么?
这是我的代码:
<h:form id="templetFile" style="height:100%">
<input type="button" value = "click me" onclick="testOnclick();"/>
<p:commandButton id="editButton" value="ceshi" styleClass="button"
action="#{advancedQueryManager.editModAndClass()}" onclick="getValddd()"
style="display:none">
<p:ajax event="dialogReturn" update="templFile"
listener="#{advancedQueryManager.onreturn()}" />
</p:commandButton>
<script type="text/javascript" >
function testOnclick() {
var a =$("#templetFile\\:editButton");
a.click();
}
function getValddd(){
alert("Allready onclick!");
}
</script>
</h:form>
如果我使用这个 js 代码 var b = document.getElementById('editButton'); 我仍然无法获取 p:commandButton 元素。为什么?以及如何使用 javascript 获取 p:commandButton?
【问题讨论】:
标签: javascript jsf callback commandbutton