Forum: Ruby on Rails focus() not rowking on IE

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A00673345921ae8c2e5570d1bd48b2e2?d=identicon&s=25 J. mp (lerias)
on 2007-02-24 00:15
Hi all,

This is more a javascript question, but hope someone can help me here.
I have the following code to show a login form using AJAX:

page.replace_html "login-form",(render :partial =>
"login/login_top_form")
page.replace_html "login_top_form_link", link_to_hide_top_login_form

page.visual_effect(:appear,"login-form")

page.delay(1) do
    page["user_email"].focus()
end

The code works well in FF and Opera, the field user_email gets the focus
but in IE I get an error:
"Can't move focus to the control because is invisible, not enable, or of
a type that does not accept the focus"

I could get a solution to verify if the page["user_email"] can get the
focus and ignore that behavior on IE, but I don't know how.

Another question: can I get the type of browser inside an RJS template?

unfortunatly many people still use IE :(
A00673345921ae8c2e5570d1bd48b2e2?d=identicon&s=25 J. mp (lerias)
on 2007-02-24 02:06
J. mp wrote:
> Hi all,
>
> This is more a javascript question, but hope someone can help me here.
> I have the following code to show a login form using AJAX:
>
> page.replace_html "login-form",(render :partial =>
> "login/login_top_form")
> page.replace_html "login_top_form_link", link_to_hide_top_login_form
>
> page.visual_effect(:appear,"login-form")
>
> page.delay(1) do
>     page["user_email"].focus()
> end
>
> The code works well in FF and Opera, the field user_email gets the focus
> but in IE I get an error:
> "Can't move focus to the control because is invisible, not enable, or of
> a type that does not accept the focus"
>
> I could get a solution to verify if the page["user_email"] can get the
> focus and ignore that behavior on IE, but I don't know how.
>
> Another question: can I get the type of browser inside an RJS template?
>
> unfortunatly many people still use IE :(

Forget it. I'm really dumb :) I found out the problem.
I was putting javascript code at the end of the partial rtml code to get
the focus on the element :(

Thanks
This topic is locked and can not be replied to.