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

Re: [ydn-javascript] Re: Make Treeview not toggle expansion on label click

Expand Messages
  • Nige White
    ... I forgot that I created TextNodes like this: var node = new YAHOO.widget.TextNode({label:label, href: # }, root, expanded); With an explicit initialization
    Message 1 of 8 , Jun 5, 2006
    • 0 Attachment
      tivacus wrote:

      >--- In ydn-javascript@yahoogroups.com, Nige White <nigelw@...> wrote:
      >
      >
      >>tivacus wrote:
      >>
      >>
      >>
      >>>--- In ydn-javascript@yahoogroups.com, "exguardianreader" <nigelw@>
      >>>wrote:
      >>>
      >>>
      >>>
      >>>
      >>>>--- In ydn-javascript@yahoogroups.com, "tivacus" <pcavit@> wrote:
      >>>>
      >>>>
      >>>>
      >>>>
      >>>>>I create:
      >>>>>
      >>>>> var node1 = new YAHOO.widget.TextNode("Tech", root, false);
      >>>>> new customTreeNode(node1);
      >>>>>
      >>>>>I get an error "this.element has no properties", referring to this
      >>>>>
      >>>>>
      >>>>>
      >>>>>
      >>>line:
      >>>
      >>>
      >>>
      >>>
      >>>>> this.id = this.element.id;
      >>>>>
      >>>>>For whatever reason id.getLableEl() is returning null while I'm
      >>>>>setting this stuff up. That combined with my onLabelClick being
      >>>>>
      >>>>>
      >wonky
      >
      >
      >>>>>(it does whatever I ask but still expands/contracts the children)
      >>>>>makes me think I don't understand this all that well.
      >>>>>
      >>>>>Hopefully that made sense, I know it's a little on the long side.
      >>>>>
      >>>>>
      >>>>>
      >>>>>
      >>>>I get what you're doing. You've hit the shortcomings of the current
      >>>>incarnation of TreeView. The LabelEl does not exist until the new
      >>>>node's parent has been refreshed which causes a whole load of
      >>>>innerHTML to be concatenated up and splatted out into the document.
      >>>>
      >>>>If you look how I create new tree nodes, you'll see that after every
      >>>>creation, I refresh the parent node.
      >>>>
      >>>>I think you just need
      >>>>
      >>>> root.refresh();
      >>>>
      >>>>After the creation of the TextNode.
      >>>>
      >>>>
      >>>>
      >>>>
      >>>>
      >>>Tried that, no go. The page is at http://tivac.com/reader/ if you
      >>>wanted to take a look at the JS and tell me what I'm still doing
      >>>wrong. If not I understand, debugging other people's JS is a pain in
      >>>the ass.
      >>>
      >>>
      >>>
      >>>
      >>The tree needs to have been drawn. Call the draw() method as soon as
      >>
      >>
      >you
      >
      >
      >>instantiate it if you want access to labelEls as soon as they're added
      >>and refreshed.
      >>
      >>Nige
      >>
      >>_____________________________________________________________________
      >>This message has been checked for all known viruses. Virus scanning
      >>powered by Messagelabs http://www.messagelabs.com For more information
      >>e-mail : hostmaster@...
      >>
      >>
      >>
      >
      >Obviously I'm missing something important, while adding the draw
      >function at the top got the errors to go away it was still calling the
      >onclick function I defined in customTreeNode and then happily calling
      >the toggle method of the generic Node object.
      >
      >After reading through treeview.js some more I discovered that if I
      >just set every node's href property to '#' I could get the
      >functionality I was looking for. It isn't a great fix, but it works
      >and it's better than using .toggle() in the onclick.
      >
      I forgot that I created TextNodes like this:

      var node = new YAHOO.widget.TextNode({label:label, href:"#"},
      root, expanded);

      With an explicit initialization object setting the URL to "#".

      Yes, it's annoying that everything seems to be an <a> - it seems utterly
      pointless - the text should just be in a <span>.

      All the YUI MenuItems are anchors too. I don't necessarily want that -
      only if that menu entry is a link - sometimes it will just be an onclick
      method to be fired - that should be a span too unless a url is
      configured for it (The config object is called "url" in a MenuItem, and
      "href" in a TextNode!!!!!).

      Nige.

      _____________________________________________________________________
      This message has been checked for all known viruses. Virus scanning
      powered by Messagelabs http://www.messagelabs.com For more information
      e-mail : hostmaster@...
    Your message has been successfully submitted and would be delivered to recipients shortly.