Funny... I don't know if you are not understanding me, or
if I am not understanding you...
I just reviewed your graphic, and I see at the bottom, the
output of $$ which exactly describes what I posted below. Maybe I wasn't
clear, and I apologies in advance that I'm about to write further on the same
thing.
Some nodes satisfy the criteria #tree .node .nodeChildren
more than once, and as a result, will be output more than once by the $$
function.
The node id node_3_children satisfies the criteria $('#tree
.node .nodeChildren') once for nodeID node_1, and once again for nodeID
node_3. The problem here is #tree .node .nodeChildren allows any
number of elements to appear between these attributes: e.g., there may be
3 <div class="node">, all of class .node, between #tree .node and
.nodeChildren. If you want to specify direct descendents only, you could
try $$('#tree > .node > .nodeChildren'), but I don't know if $$ supports
direct descendents. It probably does, but I've never had the
opportunity to test. In my experience, nothing works until you see
it work.
Another solution if you want the nodeChildren only once,
you could use $$('.nodeChildren') which will match each .nodeChildren only
once.
Sorry if I'm not understanding your concern. Maybe
someone else can clear up the confusion.
Sam
yes, I expect $$('#tree .node .nodeChildren') to return exactly those two elements, but if you look along the bottom of the image where I've called $$('#tree .node .nodeChildren') in the _javascript_ Console you'll see that it returns node_3_children twice
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Peiris
Sent: Sunday, August 13, 2006 12:53 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] Prototype $$ Question
On 8/13/06, Sam <[EMAIL PROTECTED]> wrote:Take a look at this:
http://img238.imageshack.us/img238/5752/prototypeselectorduplicatesld7.png
The image shows that $$ returns duplicates, is it supposed to do that, or is my CSS/HTML wrong?I don't understand your image, but glancing at the HTML, I can see that ID node_3_children satisfies $$('#tree .node .nodeChildren') once for nodeID node_1, and again for nodeID node_3.Sam
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
--
============================
Brian Peiris
Brampton, Ontario, Canada
[EMAIL PROTECTED] or [EMAIL PROTECTED]
============================
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs