It's me. I realize it's me, but I just can't wrap my brain around it.
So I have 120-ish form fields, and for each of the form fields I need
to go up to the field's container div.
I replaced a large chunk of DOM traversal code (recursive checks of
parentNode until the correct condition is reached -- selector is
matched -- approximately 2 iterations) with the Prototype code of
$(element).up('div.field_control')
That line looks about right.
So (expect the so, it's a story) performance on the form took a huge
hit (processing time increased by factor of 5 to 10).
As I stepped through the code, I saw that Element.up used
element.ancestors(), and ... well, it must be me.
Analogy: I want to find your (yes, YOUR) most recent ancestor whose
name was Joe. $(you).up('joe') -- right? Yes, given names are
tagNames.
It turns out that the procedure is to find all of your (I'm still
talking about you) ancestors up to Adam (it's just a name; somebody
had to kick it off) and then iterate through them to find the most
recent match.
I don't suppose there should be a way to shortcut the recursion to
actually stop when a match is found instead of (in my case) 12 more
recursion instances so that performance doesn't take a sevenfold hit
(2 to 14 recursion instances) without sacrificing the beauty of the
syntax. I sure wish there was though.
I'm sure it's just something I'm missing, and I am fully ready to
accept a logical explanation. I just need some help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---