Hi, I''m having problems with the arrays created by $$ in IE6/7 and I''m sure the answer must be simple (it would be in jQuery lol). They work fine in FF/Safari.>From reading the Prototype api it says the arrays created by thehelpers $ and $$ are of extended objects and so you should be able to do stuff to them no problems. So I''d have thought that doing something like: var footerLiAmount = ($$(''#footer ul li'').length) - 1; $$(''#footer ul li'')[footerLiAmount].addClassName(''last''); would be fine. But alas, its not for me. I can get IE to output the array length and tell me each thing in the array is an object. I just cant then get it to use any of the items individually in the array. (applying something to all the matched elements is easy enough using invoke: $$(''#footer .foo'').invoke(''addClassName'', ''bar''); or if you must, each, if you need to chain) Ok so you might be wondering why I dont just use: $$(''#footer ul li:last'').addClassName(''last''); or $$(''#footer ul li:last-child'').addClassName(''last''); but they dont work for me. So where am I going wrong? I''m perhaps using prototype all wrong - I come from a CSS and the first js framework I picked up was jQuery and perhaps prototype js users dont try and do so many CSS selector based functions I dunno. XHTML 1 transitional documents, prototype 1.6.0_rc0 (same problems with 1.5.1), scriptaculous 1.7.0 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Markus Hammer
2007-Sep-25 11:48 UTC
Re: prototype.js: $$ arrays in IE (:last-child, :last)
$$() returns you an array. so instead of
$$(''#footer ul
li:last-child'').addClassName(''last'');
you''d have to do:
$$(''#footer ul
li:last-child'').invoke(''addClassName'',''last'');
or
$$(''#footer ul
li:last-child'')[0].addClassName(''last'');
On 25 Sep., 13:12, 13twelve
<13twe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m having problems with the arrays created by $$ in IE6/7 and
I''m
> sure the answer must be simple (it would be in jQuery lol). They work
> fine in FF/Safari.
>
> >From reading the Prototype api it says the arrays created by the
>
> helpers $ and $$ are of extended objects and so you should be able to
> do stuff to them no problems.
>
> So I''d have thought that doing something like:
>
> var footerLiAmount = ($$(''#footer ul li'').length) - 1;
> $$(''#footer ul
li'')[footerLiAmount].addClassName(''last'');
>
> would be fine. But alas, its not for me.
> I can get IE to output the array length and tell me each thing in the
> array is an object. I just cant then get it to use any of the items
> individually in the array.
>
> (applying something to all the matched elements is easy enough using
> invoke: $$(''#footer
.foo'').invoke(''addClassName'',
''bar''); or if you
> must, each, if you need to chain)
>
> Ok so you might be wondering why I dont just use:
>
> $$(''#footer ul
li:last'').addClassName(''last'');
>
> or
>
> $$(''#footer ul
li:last-child'').addClassName(''last'');
>
> but they dont work for me.
>
> So where am I going wrong?
>
> I''m perhaps using prototype all wrong - I come from a CSS and the
> first js framework I picked up was jQuery and perhaps prototype js
> users dont try and do so many CSS selector based functions I dunno.
>
> XHTML 1 transitional documents, prototype 1.6.0_rc0 (same problems
> with 1.5.1), scriptaculous 1.7.0
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
works fine in FF
but in IE - no joy
in a linked js file:
document.observe("contentloaded", function() {
$$(''#footer ul
li:last-child'').invoke(''addClassName'',''last'');
}
as you suggested and no joy.
I also tried:
$$(''#footer ul
li:last-child'')[0].addClassName(''last'');
and
$$(''#footer ul
li:last-child'').first().addClassName(''last'');
and
$$(''#footer ul
li:last-child'').last().addClassName(''last'');
also no joy
Is this just my IE7? driving me insane!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Markus Hammer
2007-Sep-25 12:27 UTC
Re: prototype.js: $$ arrays in IE (:last-child, :last)
thats really odd, might be worth to check what the object returned by $
$(''#footer ul li:last-child'') is like.
IE7 debugging using alert() for the win :P.
On 25 Sep., 14:07, 13twelve
<13twe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> works fine in FF
>
> but in IE - no joy
>
> in a linked js file:
>
> document.observe("contentloaded", function() {
> $$(''#footer ul
li:last-child'').invoke(''addClassName'',''last'');
>
> }
>
> as you suggested and no joy.
>
> I also tried:
> $$(''#footer ul
li:last-child'')[0].addClassName(''last'');
> and
> $$(''#footer ul
li:last-child'').first().addClassName(''last'');
> and
> $$(''#footer ul
li:last-child'').last().addClassName(''last'');
>
> also no joy
>
> Is this just my IE7? driving me insane!
--~--~---------~--~----~------------~-------~--~----~
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 thought at first it was due to Dan Webbs Low Pro.js (http://
www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype)
so I took it out and ran with
document.observe("contentloaded", function() {
rather than
Event.onReady(function() {
Am foxed by this. So yeah, I''ll be alerting out in ie6 and 7 and
hoping for a win.
IE != ftw
I take it no one else has had issues with :last, :last-child or simply
selecting an item out of the array of returned objects from $$ like $$
(''div.foo'')[3].hide(); in IE ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---