...

View Full Version : jQuery keep or set focus on site when using .load



hacking_mike
10-28-2009, 10:52 PM
I have a text selected on my site. Then I click a button which uses the load function to show a html form in a dialog. When I start filling out te form, the focus on my selected text is lost (text is deselected). How can I keep the focus or get it back when the dialog closes?

Fumigator
10-29-2009, 12:23 AM
Are you talking about "focus" (the cursor is sitting in the text box ready for entry), or "selected text" (you've dragged your mouse over some text to highlight it)? Two different things and we can manipulate one (focus) via Javascript but not the other (highlight).

hacking_mike
10-29-2009, 08:08 AM
I'm talking about selected text but maybe focus might work. How do I do that?

Fumigator
10-29-2009, 05:09 PM
The load function can have a callback function which will be executed once the Ajax call returns from loading an element. You can put any Javascript or jQuery commands in that callback; jQuery has a focus() function you can use.

http://docs.jquery.com/Ajax/load#urldatacallback

http://docs.jquery.com/Events/focus



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum