pete-oWFMc0dWE16w5LPnMra/2Q@public.gmane.org
2006-Nov-13 22:09 UTC
Element.childrenWithClassName - deprecated?
I am running script.aculo.us v1.6.5 and it would seem as though Element.childrenWithClassName has disappeared from this build. Further, if I pull it from an earlier version and put it in my application.js, it reports that it''s not a function. Any idea what''s goin on, folks? Thomas? Pete --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I haven''t used prototype for so long so I never used the method that you referring to, but it definitely sounds like that method now is changed into this one: document.getElementsByClassName(className, parentElement) hope that helps ;) //Martin --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-14 01:12 UTC
Re: Element.childrenWithClassName - deprecated?
Hi Pete-> I am running script.aculo.us v1.6.5 and it would seem as though > Element.childrenWithClassName has disappeared from this build.There are several options now. As Martin suggested, you can use document.getElementsByClassName(''widget'', ''sidebar'') where ''widget'' is the class name and ''sidebar'' is the parent element (the parentElement argument first appeared in Prototype 1.4). In Prototype 1.5, getElementsByClassName is a method on all extended DOM elements: $(''sidebar'').getElementsByClassName(''widget'') You can also use getElementsBySelector: $(''sidebar'').getElementsBySelector(''.widget'') which is merely a wrapper around Selector.findChildElements: Selector.findChildElements($(''sidebar''), [''.widget'']) And if you need only a single child element, use the down method: $(''sidebar'').down(''.widget'') // first child matching .widget $(''sidebar'').down(''.widget'', 3) // fourth child matching .widget -- sam --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Sam, welcome back from wherever you''ve been hiding! I did end up re-writing the function to use document.getElementsByClassName. On a personal note, it''s nice to be at the point where I can look at something that isn''t working, and see several alternative techniques. I owe Prototype a lot for that flexibility. The issue really was that at this point there are many excellent open source modules which rely on specific prototype versions, and to a lesser degree, script.aculo.us versions. That some of these things would fall out of date as their internal workings occasionally rely on "the old way" is not revelatory. However, the code in question was Sebastien Gruhier''s Prototype Carousel widget, (http://prototype-carousel.xilinus.com/) which is well designed, fairly recent, and perhaps unfortunately, widely used. I say unfortunately only because the moment people upgrade their scripts - or soon, Rails 1.2 - they are in for a nasty surprise. So, if I have a point to make, I would love to see these things discussed openly: - Prototype roadmap... what''s coming, what''s changing, what''s going away? - Deprecated function list, with bonus points for documentation on their replacements I know that there''s now a team of highly trained killer elves working on Prototype stuff, and the end result is going to kick ass. In the meantime, it''s a bit hectic when functions start disappearing without fanfare. Pete ps. From the looks of the latest RC, it''s apparently time we all start mastering XPath. On 13-Nov-06, at 8:12 PM, sstephenson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > Hi Pete- > >> I am running script.aculo.us v1.6.5 and it would seem as though >> Element.childrenWithClassName has disappeared from this build. > > There are several options now. As Martin suggested, you can use > > document.getElementsByClassName(''widget'', ''sidebar'') > > where ''widget'' is the class name and ''sidebar'' is the parent element > (the parentElement argument first appeared in Prototype 1.4). In > Prototype 1.5, getElementsByClassName is a method on all extended DOM > elements: > > $(''sidebar'').getElementsByClassName(''widget'') > > You can also use getElementsBySelector: > > $(''sidebar'').getElementsBySelector(''.widget'') > > which is merely a wrapper around Selector.findChildElements: > > Selector.findChildElements($(''sidebar''), [''.widget'']) > > And if you need only a single child element, use the down method: > > $(''sidebar'').down(''.widget'') // first child matching .widget > $(''sidebar'').down(''.widget'', 3) // fourth child matching .widget > > -- > sam > > > >Pete Forde: Partner at Unspace Interactive contact | pete-oWFMc0dWE16w5LPnMra/2Q@public.gmane.org - 416.548.8444 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Nov-14 07:55 UTC
Re: Element.childrenWithClassName - deprecated?
Pete Forde a écrit :> However, the code in question was Sebastien Gruhier''s Prototype > Carousel widget, (http://prototype-carousel.xilinus.com/) which is > well designed, fairly recent, and perhaps unfortunately, widely used. > I say unfortunately only because the moment people upgrade their > scripts - or soon, Rails 1.2 - they are in for a nasty surprise.At any rate, I''ll notify Sébastien about this, so he gets a chance to fix it ASAP.> ps. From the looks of the latest RC, it''s apparently time we all > start mastering XPath.XPath is a useful tool to have at your belt anyhow. With browsers increasingly implementing DOM 3 XPath (OK, true enough, you''ll have to wait for another loooong while before IE burps it out), this makes for efficient-yet-fine-grained element selection. However, I don''t see a very near future where Prototype would rely extensively on it w/o alternatives. And the full XPath syntax is too large to be usefully implemented from within Prototype (well, there are existing implementations out there, like GoogleAJAXSLT''s xpath.js, but most of them are slightly incomplete anyhow). This syntax is also kinda inconsistent in some places (just look at the syntactic similitude between axes and functions, which is confusing at first). So don''t fidget too much on XPath if your sole source of apparent need for it is Prototype. Of course, if you''re harvesting large XML datasets as a daily matter, that''s another matter entirely :-) -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a lot Pete, I have updated Prototype Carousel widget, (http:// prototype-carousel.xilinus.com/). In fact, Element.childrenWithClassName was in effect.js but I found nothing about it in the 1.6.5 change log (http://dev.rubyonrails.org/ browser/spinoffs/scriptaculous/CHANGELOG?rev=5468) which is not very cool. Now I have to check my other projects :( Seb On Nov 14, 2006, at 8:55 AM, Christophe Porteneuve wrote:> > Pete Forde a écrit : >> However, the code in question was Sebastien Gruhier''s Prototype >> Carousel widget, (http://prototype-carousel.xilinus.com/) which is >> well designed, fairly recent, and perhaps unfortunately, widely used. >> I say unfortunately only because the moment people upgrade their >> scripts - or soon, Rails 1.2 - they are in for a nasty surprise. > > At any rate, I''ll notify Sébastien about this, so he gets a chance to > fix it ASAP. > >> ps. From the looks of the latest RC, it''s apparently time we all >> start mastering XPath. > > XPath is a useful tool to have at your belt anyhow. With browsers > increasingly implementing DOM 3 XPath (OK, true enough, you''ll have to > wait for another loooong while before IE burps it out), this makes for > efficient-yet-fine-grained element selection. > > However, I don''t see a very near future where Prototype would rely > extensively on it w/o alternatives. And the full XPath syntax is too > large to be usefully implemented from within Prototype (well, there > are > existing implementations out there, like GoogleAJAXSLT''s xpath.js, but > most of them are slightly incomplete anyhow). > > This syntax is also kinda inconsistent in some places (just look at > the > syntactic similitude between axes and functions, which is confusing at > first). > > So don''t fidget too much on XPath if your sole source of apparent need > for it is Prototype. Of course, if you''re harvesting large XML > datasets > as a daily matter, that''s another matter entirely :-) > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Element.childrenWithClassName() in script.aculo.us was always meant as an internal method, dating back from the dark ages of script.aculo.us-- the internal usage is now replaced by using the much more powerful Selector API. Sorry for the confusion, the corresponding CHANGELOG entry is: * Do some refactoring to make use of Prototype 1.5 functionalities and save LOC (see http://dev.rubyonrails.org/changeset/5174) btw, please, please try using script.aculo.us edge (that is, latest SVN). edge is nearly always perfectly stable, and this way we can find bugs like this much easier (for example, this particular change was on September 24!). :) -Thomas Am 14.11.2006 um 09:22 schrieb Sébastien Gruhier:> > Thanks a lot Pete, I have updated Prototype Carousel widget, (http:// > prototype-carousel.xilinus.com/). > In fact, Element.childrenWithClassName was in effect.js but I found > nothing about it in the 1.6.5 change log (http://dev.rubyonrails.org/ > browser/spinoffs/scriptaculous/CHANGELOG?rev=5468) > which is not very cool. > > Now I have to check my other projects :( > Seb > > > On Nov 14, 2006, at 8:55 AM, Christophe Porteneuve wrote: > >> >> Pete Forde a écrit : >>> However, the code in question was Sebastien Gruhier''s Prototype >>> Carousel widget, (http://prototype-carousel.xilinus.com/) which is >>> well designed, fairly recent, and perhaps unfortunately, widely >>> used. >>> I say unfortunately only because the moment people upgrade their >>> scripts - or soon, Rails 1.2 - they are in for a nasty surprise. >> >> At any rate, I''ll notify Sébastien about this, so he gets a chance to >> fix it ASAP. >> >>> ps. From the looks of the latest RC, it''s apparently time we all >>> start mastering XPath. >> >> XPath is a useful tool to have at your belt anyhow. With browsers >> increasingly implementing DOM 3 XPath (OK, true enough, you''ll >> have to >> wait for another loooong while before IE burps it out), this makes >> for >> efficient-yet-fine-grained element selection. >> >> However, I don''t see a very near future where Prototype would rely >> extensively on it w/o alternatives. And the full XPath syntax is too >> large to be usefully implemented from within Prototype (well, there >> are >> existing implementations out there, like GoogleAJAXSLT''s xpath.js, >> but >> most of them are slightly incomplete anyhow). >> >> This syntax is also kinda inconsistent in some places (just look at >> the >> syntactic similitude between axes and functions, which is >> confusing at >> first). >> >> So don''t fidget too much on XPath if your sole source of apparent >> need >> for it is Prototype. Of course, if you''re harvesting large XML >> datasets >> as a daily matter, that''s another matter entirely :-) >> >> -- >> Christophe Porteneuve a.k.a. TDD >> "[They] did not know it was impossible, so they did it." --Mark Twain >> Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org >> >>> > > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---