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>我的 JQuery 代码如下所示:My JQuery code look like this :$(document).ready( function(){ $("#myForm:search").change()( function(){ if ($(this).val()) { document.getElementById("download").style.display='block'; } } ); })我的按钮Downalod"总是隐藏的,我的 jquery 文件包含在我的 xhtml 页面中.My button "Downalod" is always hidden and my jquery file is included in my xhtml page.推荐答案你可以试试这个.<p:commandButton id="search" value="Search" action="#{myBean.search}" oncomplete="downloadWV.jq.show()"/><p:commandButton id="download" widgetVar="downloadWV" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" style="display:none"> <p:fileDownload value="#{myBean.file}" /></p:commandButton> 这篇关于如何禁用/启用按钮(素数)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 18:02