I want to open a p:dialog in a js file. My code is below:
<h:outputScript name="js/check.js"/>
<p:dialog id="dialog1" widgetVar="ex" >
</p:dialog>
In the js file I have written a function and inside that I have tried ex.show(); but it says ex is undefined.
Similarly I also want to invoke a p:commandButton in that file and I tried
document.getElementById("hformid:commandbuttonid").click(); and it says
document.getElementById("hformid:commandbuttonid") is null. How to solve it?
May be 'ex' is defined after your 'check.js' script is executed. Assuming your are using JQuery, try something like
$(document).ready ( function() {
ex.show();
});
So 'ex.show();' will be executed after the whole page is parsed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With