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?
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
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).
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
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.