> In this case, yeah, it sounds like a storing the answer in a variable > is the easiest.
Yeah, I'm still kicking myself for overcomplicating matters. Funny how you can feel so productive during a late-night coding session... and then wake up to a mess of stupid code. =P > 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). Ah, right, thanks for the suggestion. Unfortunately, since about 95% of the DOM is inside that parent element, it probably won't buy me much. Sounds like there's something to this Element.hasClassName ineffiency, though. See this recent discussion on the Prototype Core list (especially the last message): http://groups.google.com/group/prototype-core/browse_thread/thread/aecbf8e008782d6a . This makes it sound like the problem is only with getElementsByClassName, but perhaps something similar is happening with the IE implementation of $$? Tom, thanks for your help with this. Altay > > 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 $$?- Hide quoted > > text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
