Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open p:dialog inside a js file?

Tags:

primefaces

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?

like image 447
user1788115 Avatar asked Feb 01 '26 09:02

user1788115


1 Answers

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.

like image 157
Burghard Britzke Avatar answered Feb 03 '26 10:02

Burghard Britzke