javascript - How to preserve text selection when opening a jQuery dialog -


Using jQuery Dialogs I came to the following cone (tested in FF3):

  1. User
  2. Select the code
  3. One HTML on the page)

    So, I like this a strange (and annoying) bug or a kind of tree, but maybe there is a good explanation for that and what's the most I Interested, how to preserve this text selection after opening the dialog Or?

    Here are some code:

      function getSelectedText () {var t; If (D.Jet Selection) T = D. Jatosolation (); Otherwise if (D. education) T = D. Selection. If (T.text! = Undefined) T = T.text; If (! T = t == '') {var a = d.getElementsByTagName ('textarea'); For (var i = 0; i & lt; a.length; ++ i) {if (a [i] .selectionStart! = Undefined & a [i] Select Selection! = A [i] .selectionEnd) {T = a [i] .value.substring (a [i]. Selection selection, a [i] .selectionEnd); break; }}} Return T; } $ ("# Dialog"). Dialog ({Auto Open: False, BGframe: False, Height: 60, Width: 80, Model: False, Show: 'Highlight', Title: 'wc'}); Warning (getSelectedText ()); // text is $ ("# dialog"). Dialog ("open"); Warning (getSelectedText ()); // text is not selected here: (damn!  

    Thanks!

The jQuery dialog will take care of the user (you should see one of the buttons selected on the dialog). Browsers have only 1 focus, so you lose whatever you choose.

You should just retrieve the starting and ending of the user's selection before the dialog, and after that the dialog goes away Afterwards it was searched again.

I do not have any example code to get the user selection and set up, but a web search should find something for you.

Something like this:

  $ ("dialog"). Focus (function () {// save selection}} .blur (function () {// set text selection});  

[edit (nickel): see more code]


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -