IE & $$()

1 view
Skip to first unread message

Denny

unread,
Jul 16, 2008, 10:40:43 AM7/16/08
to Ruby on Rails: Spinoffs

Using Prototype 1.6.0, I recently ran into IE7's "Object does not
support this property or method" error. After a quick search, I see
the problem is usually caused by a DOM element that hasn't been
extended with Prototype's Element.Methods. I don't quite understand
what was going on in my case and hoping someone can clue me in.

The error was caused by the following line:

$$('#test-inspector form').invoke("submit");

and I was able to fix the problem by changing it to this:

$$('#test-inspector form')[0].submit();

I figured $$ would return elements that were properly extended. Is
that not the case?

Thank you,

Denny Crall

Andrew Kaspick

unread,
Jul 16, 2008, 10:44:32 AM7/16/08
to rubyonrail...@googlegroups.com
$$ returns an array... your "error" version is trying to invoke
"submit" on an array. I don't think that's what you want. Your fixed
version looks better.

Andrew Kaspick

unread,
Jul 16, 2008, 10:45:48 AM7/16/08
to rubyonrail...@googlegroups.com
You could also do $('test-inspector').down('form').submit()

Denny

unread,
Jul 16, 2008, 11:11:01 AM7/16/08
to Ruby on Rails: Spinoffs

Enumberable.invoke() invokes a method for each element in a
collection. In my case, there will always be exactly one element
returned. The original line was working fine in every browser except
IE, and from my understanding should be correct.

Thanks for your feedback.

On Jul 16, 9:44 am, "Andrew Kaspick" <akasp...@gmail.com> wrote:
> $$ returns an array... your "error" version is trying to invoke
> "submit" on an array.  I don't think that's what you want.  Your fixed
> version looks better.
>

Andrew Kaspick

unread,
Jul 16, 2008, 11:15:37 AM7/16/08
to rubyonrail...@googlegroups.com
Oh, well if that's what invoke is supposed to do on an
Enumerable(Array) then I'm not sure why the error was occurring. So
yes, I would think it would be correct as well then.
Reply all
Reply to author
Forward
0 new messages