Search code examples
javascriptrichfaces

Findind the state of rich:collapsiblePanel on change event


How to get the current state of rich:collapsiblePanel either extended or collapsed

<rich:collapsiblePanel header="Search" switchType="client" id="searchId" onswitch="checkState();">
Panel To show the Data
</rich:collapsiblePanel>

My JavaScript code is

function checkState() {
//Here how to get the current state
var st = #{rich:element('searchId')}.isExpanded();
alert(st);
}

Updated my Java Script but i'm getting the below error. We are using 4.3.4 Jars
Uncaught TypeError: document.getElementById(...).isExpanded is not a function


Solution

  • RichFaces.component("formId:panelId").isExpanded()
    

    Read the documentation.

    EDIT: for versions up to 4.5.4:

    RichFaces.component("formId:panelId").activeItem == "true"