0 Replies Latest reply on Jan 30, 2008 5:36 PM by Daniel Spangler

    rich:tree node collapses the first time I select it

    Daniel Spangler Newbie

      I have a tree as outlined below that executes an ajax operation each time a node is selected. When the page loads I use javascript to expand the entire tree. The first time I select one of the nodes it will collapse itself, but subsequent calls work fine. My initial guess is that maybe the way in which I expand the nodes via javascript leaves the tree event listeners in an unexpected state. Any suggestions would be greatly appreciated.



       <script type="text/javascript">
       //<![CDATA[
      
       {
       $(window).onload = function(){
       expandAll();
       };
       }
       function expandAll(){
       var tree = window['Richfaces_Tree_createOrderForm_question_tree'];
       var childs = tree.childs;
       expand(childs);
       }
      
       function expand(childs) {
       for (var i = 0; i < childs.length; i++) {
       var element = childs;
       var cc = element.childs;
       if (cc!=null && cc.length != 0) {
       if (element.isCollapsed){
       //element.eventCollapsionClick();
       element.expand();
       expand(cc);
       }
       }
       }
       }
       //]]>
       </script>
      
      
       <rich:tree id="question_tree" value="#{questionManagerModel.directedQuestionNode}" var="item" nodeFace="#{item.model.class.simpleName}" switchType="client">
       <rich:treeNode type="DatabaseQuestionImpl" icon="/img/blue_cloud.png">
       <h:outputText value="Q - #{item.model.questionText}">
       </h:outputText>
       <a4j:support action="#{questionManager.setCurrentNode(item)}" event="onselected">
       </a4j:support>
       </rich:treeNode>
      


      Thanks in advance,

      Daniel