onblur= ; focus()

19 views
Skip to first unread message

few1938

unread,
Jul 3, 2008, 8:05:12 AM7/3/08
to Ruby on Rails: Spinoffs
I recently posted a problem with re-focusing the cursor to a field
that had an 'onblur' event. The browser is FF3

I have found the following link that identifies the problem:
https://bugzilla.mozilla.org/show_bug.cgi?id=53579

Does prototype.js have a work-around or does anyone know a work-
around?

Frank

Trevan Richins

unread,
Jul 3, 2008, 10:31:11 AM7/3/08
to rubyonrail...@googlegroups.com

Try putting the focus() inside of a window.setTimeout. So like this:

input.observe('blur', function() {
window.setTimeout(this.focus);
});

I didn't test it but I've done things similar to get around the issue.

Frederick Polgardy

unread,
Jul 3, 2008, 10:36:31 AM7/3/08
to rubyonrail...@googlegroups.com
Watch out for binding/this issues if you're using this example - this isn't bound inside the event handler:

input.observe('blur', function() {
       window.setTimeout(function() { Element.focus(input); });
});

-Fred


On Thu, Jul 3, 2008 at 9:31 AM, Trevan Richins <deve...@ckiweb.com> wrote:
Try putting the focus() inside of a window.setTimeout.  So like this:

input.observe('blur', function() {
       window.setTimeout(this.focus);
});

I didn't test it but I've done things similar to get around the issue.

--
Science answers questions; philosophy questions answers.

few1938

unread,
Jul 3, 2008, 10:40:39 AM7/3/08
to Ruby on Rails: Spinoffs
The timeout issue has been discussed in the link.

Frank
Reply all
Reply to author
Forward
0 new messages