1

I am using linkify in textarea & i have autosave function in it. After every 3 secs the text is saved in database .I am calling linkify before saving in database.

$(".froala-element").linkify();

What problem i am facing is the focus of cursor/caret is lost due to linkify ..

I keep on writing and after autosave cursor is lost its position.. I am using froala-editor as my text editor.

user8025
  • 99
  • 1
  • 9

1 Answers1

1

You can store the caret position before you run the linkify/db-save, and then restore the caret position after its done. An example of how to store and restore caret positions is provided here:

Persisting the changes of range objects after selection in HTML

Community
  • 1
  • 1
BobbyTables
  • 4,481
  • 1
  • 31
  • 39
  • it worked but still i have some issues .. cursor is not smooth as it should be – user8025 Mar 31 '15 at 09:41
  • can you be more specific about what you mean with "not smooth"? – BobbyTables Mar 31 '15 at 09:46
  • some lag is occuring while the ajax is called – user8025 Mar 31 '15 at 12:27
  • well, im not sure how your code looks etc, but if it is: save caret - linkify - store to db - restore caret. Then you culd maybe try to swap the order to restore the caret after the linkify. You will have to research what is causing the lag etc – BobbyTables Mar 31 '15 at 12:41
  • Thanks zedd i tried few combination .. Finally Savecaret- Linkify - RestoreCaret - SavetoDB worked for me . – user8025 Apr 01 '15 at 05:55