Thank you Eric, much appreciated. I have things up and running now.
A couple additional things I don't understand how to do with my example:
How do I capture the node that the user clicks? I will need to grab
that information to make my database call.
Also, for each item in the tree, I want to build a hyperlink with
parameters. What is the best way to go about this?
I have looked everywhere for examples of a tree like this. Since I'm
not used to javascript (out of my J2EE comfort zone), I rely on a good
example, but havent' had any luck finding one)
Thanks again!
--- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:
>
> jmpow99,
>
> I've taken your code below and reworked it a bit to make it
> functional; take a look here:
>
> http://yuiblog.com/sandbox/yui/v0113/examples/treeview/dyn_ld.php
>
> There were a few issues in the code you pasted in here. Your
> singleton was not formed correctly and it wasn't clear that all of
> the functions were well-formed. However, without too many changes
> your code appears to work as desired, so you were definitely on the
> right track.
>
> Take a look at the functional example and let us know how things go
> from there.
>
> Regards,
> Eric
>
>
>
> Eric Miraglia
> Yahoo! Presentation Platform Engineering
>
>
>
> On Sep 25, 2006, at 2:13 PM, jmpow99 wrote:
>
> > I took Yahoo's dynamic tree example and started making changes to
> > statically simulate what calling the database. All data is in Arrays.
> > The buildTree method gets the first Array loaded up as the root. All
> > good.
> >
> > Now, I want to take the node the user clicks (call db with that id)
> > then load up that parent node with an array of it's children.
> >
> > I can't seem to figure out the next steps:
> >
> > 1.) How do I get a handle on the node the user clicked?
> > 2.)When I have the array of children, I'm looping through, how do I
> > assign them to their parent? This loop will only be for one parent at
> > a time.
> >
> > Thanks everyone, couldn't do it without these groups sharing
> > knowledge!
> >
> > Here is my current code:
> >
> > /*create namespace for examples:*/
> > YAHOO.namespace("example");
> >
> > /* Using Crockford's "Module Pattern": */
> > YAHOO.example.treeExample = function() {
> >
> > function buildTree() {
> >
> >
> > //create a new tree:
> > tree = new YAHOO.widget.TreeView("treeContainer");
> >
> > //turn dynamic loading on for entire tree:
> > tree.setDynamicLoad(loadNodeData, currentIconMode);
> >
> > //get root node for tree:
> > var root = tree.getRoot();
> >
> > //create dummy data for root
> > var mycars = new Array()
> > mycars[0] = "Saab"
> > mycars[1] = "Volvo"
> > mycars[2] = "BMW"
> > mycars[3] = "Ferrari"
> > mycars[4] = "Yugo"
> > mycars[5] = "Bentley"
> >
> > for (i=0;i<mycars.length;i++)
> > {
> >
> > new YAHOO.widget.TextNode(mycars[i], root, false);
> >
> > }
> >
> > tree.draw();
> > }
> >
> >
> >
> > function loadNodeData(node, fnLoadComplete) {
> >
> >
> >
> > //dummy data for bmw parent
> > var bmws = ["3 series","m series","5 series","7 series","6 series"];
> >
> > var children = bmws;
> >
> >
> > //loop through children array and need to load up the bmw parent.
> > How to do this???
> > for (var i=0; i<children.length; i++) {
> > thisModel = children[i];
> > var newNode = new YAHOO.widget.TextNode(thisModel, node, false);
> > }
> >
> > fnLoadComplete();
> > }
> >
> >
> > YAHOO.util.Event.addListener(window, "load",
> > YAHOO.example.treeExample.init, YAHOO.example.treeExample,true)
> >
> >
> >
>