Loading ...
Sorry, an error occurred while loading the content.

Bug in - YAHOO.widget.HTMLNode of TreeView UI library

Expand Messages
  • Sai Nagboth
    There is bug while using HTMLNode with hasIcon set to true and when the node has children. This is an excerpt taken from the function
    Message 1 of 2 , Feb 23, 2006
    • 0 Attachment

      There is bug while using HTMLNode with hasIcon set to true and when the node has children.

      This is an excerpt taken from the function  YAHOO.widget.HTMLNode.prototype.getNodeHtml

      if (this.hasIcon) {
      sb[sb.length] = '<td';
      sb[sb.length] = ' id="' + this.getToggleElId() + '"';
      sb[sb.length] = ' class="' + this.getStyle() + '"';
      sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">&nbsp;';
      if (this.hasChildren(true)) {
      sb[sb.length] = ' onmouseover="this.className=';
      sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'
      ';
      sb[sb.length] = this.tree.id + '
      \',' + this.index +  ').getHoverStyle()"';
      sb[sb.length] = ' onmouseout="this.className=';
      sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'
      ';
      sb[sb.length] = this.tree.id + '
      \',' + this.index +  ').getStyle()"';

      }
      sb[sb.length] = '</td>';
      }

      The code highlighted in red is in wrong place and is causing to display the html content highlighted in blue on the screen.

      The fix is very simple, as shown below

      if (this.hasIcon) {
      sb[sb.length] = '<td';
      sb[sb.length] = ' id="' + this.getToggleElId() + '"';
      sb[sb.length] = ' class="' + this.getStyle() + '"';
      sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '"';
      if (this.hasChildren(true)) {
      sb[sb.length] = ' onmouseover="this.className=';
      sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'
      ';
      sb[sb.length] = this.tree.id + '
      \',' + this.index +  ').getHoverStyle()"';
      sb[sb.length] = ' onmouseout="this.className=';
      sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'
      ';
      sb[sb.length] = this.tree.id + '
      \',' + this.index +  ').getStyle()"';

      }
      sb[sb.length] = '>&nbsp;</td>';
      }

      A simple code to test the problem..

        caddTree = new YAHOO.widget.TreeView("treeDiv2");
        var oNode = {label:"Root",id:"1"};
        var html = "<div id='123' onClick='clicked(this)'>html Node</div>"

        var tmpNode = new YAHOO.widget.TextNode(oNode,caddTree.getRoot(),false);
        var tmpNode3 = new YAHOO.widget.HTMLNode(html, tmpNode, false, true);
        var tmpNode2 = new YAHOO.widget.TextNode("html-child",tmpNode3,false);

        caddTree.draw();

      I hope yahoo will fix this in their code.  And not to forget, I really appreciate Yahoo's efforts for getting out some of their awesome code libraries.

      Sai

       

    • pnelsonsb
      Great fix! Everything is working smoothly with my TextNode and HTMLNode. Thanks Sai! - Paul
      Message 2 of 2 , Feb 23, 2006
      • 0 Attachment
        Great fix! Everything is working smoothly with my TextNode and
        HTMLNode. Thanks Sai!

        - Paul
      Your message has been successfully submitted and would be delivered to recipients shortly.