In this case, yeah, it sounds like a storing the answer in a variable
is the easiest.
One of the things I was getting at was perhaps these arbitrary edit
divs are all the children/descendants of a div with a particular id?
Thus your $$ query might be
'#myEditContainer div.edit' (you could try it with and w/o the child
selector).
TAG
On May 28, 2007, at 10:24 AM, [EMAIL PROTECTED] wrote:
> Here what's up. I've got an arbitrary number of divs, with
> class='qedit', and id='{uniqueid}_qedit'. The user can click on an
> "edit" link to open up a qedit div for editing, but s/he can only edit
> one at a time. In other words, when you click 'edit,' it should find
> and close any currently-open divs, and open the div you clicked on.
>
> Hm, now that I actually write out my requirements, I suppose I could
> simply store the currently-open id in a global, which would be a
> little more straightforward. Doh. It's time to refactor.
>
> But, for the sake of discussion -- and cause I've run into this issue
> in other situations -- here's my original implementation:
> [...]
> There are 15 of these divs on my test page.
>
> For optimization, you can see that I tried four ways to get the
> elements:
> - $$('.qedit')
> - document.getElementsByClassName('qedit')
> - $$('div.qedit')
> - find_elts_by_class( 'div', 'qedit') --> my own custom function,
> which is not DOM-specific*
>
> Anything else I should try?
>
> Here's the breakdown:
>
> 4172ms -- $$('.qedit')
> 3797ms -- document.getElementsByClassName
> 266ms -- $$('div.qedit')
> 16ms -- my custom function
>
> So clearly, looking for div.qedit instead of just .qedit helped a lot,
> but it was still trumped by my non-prototype solution. I don't get
> it. Do you see any glaring errors in my implementation of $$?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---