Home » Javascript » PrimeFaces: Uncaught TypeError: Cannot read property 'show' of undefined

PrimeFaces: Uncaught TypeError: Cannot read property 'show' of undefined

Posted by: admin June 30, 2018 Leave a comment

Questions:

I want a dailog box to display when I click on a button. But I am getting

Uncaught TypeError: Cannot read property ‘show’ of undefined

error.

Here is my code:

<div class="event_status #{periodModel.styleClass}">
                <!-- <span class="glyphicon glyphicon-certificate"></span> -->

                <h:form>

                    <h:panelGrid columns="1" cellpadding="5">
                        <p:commandButton value="Modal" onclick="PF('dlg2').show();"
                            type="button" />
                    </h:panelGrid>

                    <p:dialog id="dlg2" header="Modal Dialog" widgetVar="dlg2" modal="true"
                        height="100">
                        <h:outputText value="This is a Modal Dialog." />
                    </p:dialog>



                </h:form>
            </div>

I have also added primefaces-6.0.jar in my lib folder.

Also, I am getting the below two js errors in my console.

enter image description here

Please help me. Thanks in advance.

Answers: