views:

177

answers:

2

Hey guys,

Using jQuery, the following is not working in FF, but it is in IE

$(this).focus().select();

I looked around for this and found that you could use a timeout to get around this, but that is not something I want to do if I can avoid it. Does anyone know another way to do this and have it work in FF?

Metropolis

A: 

I've run into this before as well. I believe that the setTimeout() solution is the only way this will work in Firefox. The issue has to do with order of events processing, if I remember correctly: IE immediately changes control focus when the focus() method is invoked, but Firefox handles it by adding a focus event to the event queue, which doesn't resolve until after the current event processing has completed. The setTimeout() trick works because it adds the remainder of your code to another event to the event queue after the focus change event, causing it to resolve before your code continues processing.

Dan Story
FireFox should fix this lol. I wish that it either worked everywhere, or nowhere....Very annoying.
Metropolis
A: 

i used

$('input').focus().select();

on

 <input type="text" value="Some text" />

and it worked in firefox. maybe I dont understand what your problem exactly is.

XGreen
Are you using Linux or Windows? And what version of FF?
Metropolis