Search code examples
javascriptrangytiki-wiki

Rangy Error: deserializeRange: checksums of serialized range root node do not match after page load


I am saving the selection through rangy on my dynamic web page. But when I reload the page and restore the selections, I get the following error:

Error: deserializeRange: checksums of serialized range root node (f3909155) and target root node (c21b08a9) do not match

The page source is not changed at all and all HTML is same. I am using Tikiwiki CMS. Any ideas about this?


Solution

  • To solve this error, you need to pass the omitChecksum parameter to the serializeSelection function. This will prevent the DOM validation. serializeSelection will return the serialized form of the selection which you can save in DB or cookie.

    See the following example:

    var selObj = rangy.getSelection();
    var sel = rangy.serializeSelection(selObj, true);