I'm working with Primefaces, Initially my button is disabled, after clicking on "Search" and waiting that a search() function is finished, the button "Download" must be enabled, I tried to do this :
<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>
My JQuery code look like this :
$(document).ready(
function(){
$("#myForm:search").change()(
function(){
if ($(this).val()) {
document.getElementById("download").style.display='block';
}
}
);
})
My button "Downalod" is always hidden and my jquery file is included in my xhtml page.