Javascript: Getting and saving text selection ranges in a database -


i'm building gramma-checker system client, users can add comments/suggestions given text. when user selects text, button appear create comment/suggestion given text selection. problem comes when want save text selection range in database, along comment/suggestion.

i'm trying solve problem using rangy (http://rangy.googlecode.com/).

these ideas i'v tried far:

  • using rangy serializer serialize range. problem approach dom changing each time new comment/suggestion added, , therfore not allowing successful deserialization.
  • using rangy selection wrapper , save directly in database, idea above, target elements content changing each comment/suggestion, again makes approach not work intended.

any suggestions how solve problem appriciated.

i haven't used rangy. here 1 way approach it.

  1. get selected text element (tutorial here)

  2. then add wrapper span specific id it. (you might want fetch unique id server)

  3. then show form enter comments.

  4. on submit, send span id , comment server , store in database.

  5. when re rendering can assign class span mark , show comments on hover using css.

  6. this give system google document can comment on text.

let me know if helps or need more explanation on how accomplish individual steps.

advantage of dont need send selected text server or worry serializing. id of span wrapped in.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -