0

I have this code and I want to hide the panelGrid when i click the cancelBtn button.

<h:form id="panelSend">
        <p:growl />

        <h:panelGrid rendered="#{writeMessageBean.activateText}" id="panelGrid">
           <p:outputLabel value="header" />
           <p:inputText value="#{writeMessageBean.header}" />
           <p:outputLabel/>
           <p:inputTextarea value="#{writeMessageBean.text}" required="true"/>

           <p:commandButton value="send" action="#{writeMessageBean.send}"  
           <p:commandButton id="cancelBtn" value="cancel" />


        </h:panelGrid>

  </h:form>

And my jquery is this.

$(document).ready(function (){

        $("#panelSend\\:#panelGrid\\:#cancelBtn").click(function (){
            $("#panelSend\\:#panelGrid").hide();

         });
    });

This doesn't work. I have tried more possibilities but it´s always the same. How can i do?

tutankhamun
  • 880
  • 2
  • 11
  • 21

1 Answers1

0

Try this:

<p:commandButton id="cancelBtn" value="cancel" action="#{writeMessageBean.hidePanelGrid}" update="panelGrid" ajax="false" >

and in your writeMessageBean:

 public void hidePanelGrid() {
    activateText = false;
 }

assuming that you have a member activateText in the bean.

ranshw
  • 41
  • 5