Can't get any form field to $('#field').focus(); in facebox????

82 views
Skip to first unread message

regan

unread,
Apr 30, 2010, 6:16:44 PM4/30/10
to facebox
Hello!

No matter what I try, I can't get the cursor to focus on any field
that's loaded into facebox.

Is there a special trick to it????

say if I've got a field called... "focusonme".

<input type="text" name="focusonme" id="focusonme" value="" />

and I do..

$('#focusonme').focus();

it still WONT focus???????????

I can however alter or add a value to the field, just not FOCUS.

Anyone???

--
You received this message because you are subscribed to the Google Groups "facebox" group.
To post to this group, send email to fac...@googlegroups.com.
To unsubscribe from this group, send email to facebox+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/facebox?hl=en.

Morad

unread,
May 4, 2010, 8:05:43 AM5/4/10
to facebox
i cant reach my form elements too..

anybody can help?

kiril

unread,
May 14, 2010, 6:42:15 AM5/14/10
to facebox
Actually it must be some kind of a bug in the plugin.

I also tried to place the focus bind to a facebox event as explained
in the documentation:

$(document).bind('reveal.facebox', function() {
$("focus_me").focus();
})

but doesn't work this way neither.

Greg Milby

unread,
May 14, 2010, 7:16:39 AM5/14/10
to fac...@googlegroups.com
i heard about this before - i think there are a few work-arounds out there, so maybe it is a bug?  this link claims to fix it with a jquery plugin tho:

-----------------------
Visit My Sites!
http://1-4-u.info | Don't send insanely long links!
www.superantispyware.com/superantispyware.html?rid=3971 Remove All The Spyware - Not Just The Easy Ones!

regan

unread,
May 14, 2010, 8:14:00 AM5/14/10
to facebox
Figured out a "hack" for the focus problem.

It seems it won't focus on a loaded field, because it hasn't "quite"
finished being rendered before the focus() is called.

So you need to put your focus call into a setTimeout function, even if
it has a timeout of 0. So it waits until the document is drawn, then
focuses.

Works.

<script type="text/javascript" language="javascript">
setTimeout( function() { $("#focusonme").focus(); }, 0 );
</script>

gmi...@gmail.com

unread,
May 14, 2010, 8:16:46 AM5/14/10
to fac...@googlegroups.com

was that with the 'basic' jquery? or did you have to add anything else?
glad it's working for you.

regan

unread,
May 14, 2010, 8:24:15 AM5/14/10
to facebox
No, just plain jquery - I didn't add anything else.

It's just a minute timing issue between when the page (elements) have
finished loading in the modal and when the focus() is called.

I haven't looked at the facebox code yet to see if I can fix it there,
tomorrow. If I figure out a facebox fix will post it here.



On May 15, 12:16 am, gmi...@gmail.com wrote:
> was that with the 'basic' jquery? or did you have to add anything else?
> glad it's working for you.
>

Greg Milby

unread,
May 14, 2010, 8:33:08 AM5/14/10
to fac...@googlegroups.com
nice work regan - works like a charm:


glad i found you guys - always nice to find some people who like to try new ideas.

do you know of any conventional (or unconventional) hacks for facebox?  things that mimic or bypass lightbox features?  (like cataloging - grouping by id, transition effects/etc). 
i'll be glad to help organize a pile of ideas, and submit them in a facebox wiki or something.  

i ask because i'd like to modify the colors of the corners... sounds petty, but i would really like the facebook blue color (or any other color i might like to try down the road), and yes, i'm that bad with gimp that i can't make the corners without a template :)
Reply all
Reply to author
Forward
0 new messages