It works!  Thank you muchly.  Valuable for learning, too.

Now the code executes far enough to uncover another similar problem
which I think will go to my basic understanding of Javascript.  I'm
expecting it to act like PHP but I keep getting functions where I
expect values:

given:

attr: {
   edges: []
}


initialize: function($super,cv, id, attr) {

   // attr at this point is an object.  nice.

    var myedges=$H(attr.edges);
    myedges.each(function(edge, id) {

       // in the first place, I didn't expect to even get here because
myedges is an empty Hash, has no members.

      // but this shows the source code of a function!  I wanted the
value of a member of attr.edges (if it existed).
       alert(edge);

    }, this);





On Jul 10, 4:15 pm, Rick Waldron <waldron.r...@gmail.com> wrote:
> The result your getting is completely correct, you're just missing one
> aspect...
> Take a look:
>
> http://jsbin.com/anefa
>
> (view source... )
>
> On Fri, Jul 10, 2009 at 4:57 PM, ronman <ron.new...@gmail.com> wrote:
>
> > Hi,
> > I've been puzzling over this for a couple of days and finally admit I
> > need help.  I have a Hash of objects which I iterate over using each:
>
> >  $H(data.nodes).each(function(mynode,id) {
> >      alert(mynode);
> >      // do something with mynode
> >    },this);
>
> > What I get back for 'mynode' is
> > 'nodename', [object Object]
>
> > instead of what I need:
> > [object Object]
>
> > Here's the structure of the Hash, copied from Firebug.  If there's a
> > better way to represent this, let me know:
>
> > data:      Object nodes=Object size=[2]
> >  nodes:   Object node0=Object node1=Object
> >    node0:   Object label='node 0' height=0.44
> >    node1:   Object label='node 1' height=0.44
> >    node2:   Object label='node 2' height=0.44 width=1
> >    node3:   Object label='node 3' height=0.44 width=1
> > .
> > apparently the _each method of Hash in Prototype can't understand this
> > structure, but I'm not seeing why it returns
> > 'nodename' and a comma before the object instead of just the object.
>
> > Help!
>
> > Ron
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to