我正在使用Primefaces,最初我的按鈕被禁用,點擊「搜索」並等待搜索()功能完成後,必須啓用按鈕「下載」,我試圖這樣做:如何禁用/啓用按鈕(primefaces)?
<h:form id="myForm" method="post">
<p:commandButton id="search" value="Search" action="#{myBean.search}"/>
<p:commandButton id="download" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" style="display:none">
<p:fileDownload value="#{myBean.file}" />
</p:commandButton>
</h:form>
我的jQuery代碼如下所示:
$(document).ready(
function(){
$("#myForm:search").change()(
function(){
if ($(this).val()) {
document.getElementById("download").style.display='block';
}
}
);
})
我的按鈕「Downalod」總是隱藏和我的jQuery的文件包括在我的XHTML頁面。
歡迎您:) @Angelika –
另一個問題,請@Hatem,如果我想downloding文件後再次隱藏我的下載按鈕? – Angelika
不幸的是,monitorDowonload的stop()永遠不會因爲Primefaces中的一個bug而被調用。查看更多http://stackoverflow.com/questions/20663551/js-function-not-triggered-with-primefaces-monitordownload –