Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    keep or set focus on site when using .load

    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?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    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).

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm talking about selected text but maybe focus might work. How do I do that?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    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.

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

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •