¡@

Home 

2014/10/16 ¤W¤È 12:07:08

jquery Programming Glossary: restoreselection

Persisting the changes of range objects after selection in HTML

http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html

this Demo http jsfiddle.net WeWy7 3 Code var saveSelection restoreSelection if window.getSelection document.createRange saveSelection function.. return start start end start range.toString .length restoreSelection function containerEl savedSel var charIndex 0 range document.createRange.. start start end start selectedTextRange.text.length restoreSelection function containerEl savedSel var textRange document.body.createTextRange..

Left and right button misbehaving when trying to add an empty span to contenteditable div

http://stackoverflow.com/questions/16331088/left-and-right-button-misbehaving-when-trying-to-add-an-empty-span-to-contentedi

selection caret position the solution to that was to do restoreSelection after you changed the contents of your element which essentially.. _spanElem _fullText.slice _caretPos _result.html text restoreSelection _result.get 0 _savedSel added this offsetPos '.spanPos' .offset..

Preserve text selection in contenteditable while interacting with jQuery UI Dialog and text input

http://stackoverflow.com/questions/3315824/preserve-text-selection-in-contenteditable-while-interacting-with-jquery-ui-dial

you should store in a variable which you later pass to restoreSelection function saveSelection if window.getSelection sel window.getSelection.. return document.selection.createRange return null function restoreSelection range if range if window.getSelection sel window.getSelection..

Insert link in contenteditable element

http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element

return document.selection.createRange return null function restoreSelection savedSel if savedSel if window.getSelection sel window.getSelection..

Should jQuery's $(form).submit(); not trigger onSubmit within the form tag?

http://stackoverflow.com/questions/645555/should-jquerys-form-submit-not-trigger-onsubmit-within-the-form-tag

Persisting the changes of range objects after selection in HTML

http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html

and deserialize it again on reload using something like this Demo http jsfiddle.net WeWy7 3 Code var saveSelection restoreSelection if window.getSelection document.createRange saveSelection function containerEl var range window.getSelection .getRangeAt.. range.startOffset var start preSelectionRange.toString .length return start start end start range.toString .length restoreSelection function containerEl savedSel var charIndex 0 range document.createRange range.setStart containerEl 0 range.collapse true.. var start preSelectionTextRange.text.length return start start end start selectedTextRange.text.length restoreSelection function containerEl savedSel var textRange document.body.createTextRange textRange.moveToElementText containerEl textRange.collapse..

Left and right button misbehaving when trying to add an empty span to contenteditable div

http://stackoverflow.com/questions/16331088/left-and-right-button-misbehaving-when-trying-to-add-an-empty-span-to-contentedi

was a misbehaving keys was actually loss of original text selection caret position the solution to that was to do restoreSelection after you changed the contents of your element which essentially sets back the caret to where it was. I also changed the.. _result.remove '.spanPos' var text _fullText.slice 0 _caretPos _spanElem _fullText.slice _caretPos _result.html text restoreSelection _result.get 0 _savedSel added this offsetPos '.spanPos' .offset Get the code from the modified fiddle http jsfiddle.net..

Preserve text selection in contenteditable while interacting with jQuery UI Dialog and text input

http://stackoverflow.com/questions/3315824/preserve-text-selection-in-contenteditable-while-interacting-with-jquery-ui-dial

saveSelection returns you a Range or TextRange object that you should store in a variable which you later pass to restoreSelection function saveSelection if window.getSelection sel window.getSelection if sel.getRangeAt sel.rangeCount return sel.getRangeAt.. else if document.selection document.selection.createRange return document.selection.createRange return null function restoreSelection range if range if window.getSelection sel window.getSelection sel.removeAllRanges sel.addRange range else if document.selection..

Insert link in contenteditable element

http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element

else if document.selection document.selection.createRange return document.selection.createRange return null function restoreSelection savedSel if savedSel if window.getSelection sel window.getSelection sel.removeAllRanges for var i 0 len savedSel.length..

Should jQuery's $(form).submit(); not trigger onSubmit within the form tag?

http://stackoverflow.com/questions/645555/should-jquerys-form-submit-not-trigger-onsubmit-within-the-form-tag