3

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?

Arvind Bhardwaj
  • 5,231
  • 5
  • 35
  • 49
  • It's likely the DOM must be different in some way. Is the DOM altered by scripts that run when the page loads, for example? And are you using the same browser? If you have an example page then I'll take a look. – Tim Down Dec 29 '12 at 18:33
  • @TimDown I dont have the live example right now. But I am using the same browser without any modification in the page source (I compared the page sources and those are same). I dont know how to handle this :( – Arvind Bhardwaj Jan 02 '13 at 03:58
  • using the same lib , facing the exact same issue , were you able to find a fix for this one ? @ArvindBhardwaj – Nishant Jani Jan 19 '13 at 21:12
  • possible duplicate of [Range.deserializeSelection checksum error?](http://stackoverflow.com/questions/11586115/range-deserializeselection-checksum-error) – Florian Margaine Jan 20 '13 at 09:07
  • @FlorianMargaine , that SO question deals with iFrame , in my case i dont have an iFrame – Nishant Jani Jan 20 '13 at 10:13
  • 1
    @user1537158 see my answer below. – Arvind Bhardwaj Jan 21 '13 at 10:50

2 Answers2

4

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);
Arvind Bhardwaj
  • 5,231
  • 5
  • 35
  • 49
  • The checksums failing to match means that something is different in the DOM and therefore deserialization has a good chance of failing. I'd be interested in seeing a demo page. – Tim Down Jan 21 '13 at 09:45
  • @ArvindBhardwaj , TimDown , can you help me with my question http://stackoverflow.com/questions/14416524/restore-multiple-selections-from-db-using-rangy , im facing the exact same issue , i have created JS fiddle too for demonstration – Nishant Jani Jan 21 '13 at 11:53
  • @TimDown could you help me with my SO question http://stackoverflow.com/questions/14416524/restore-multiple-selections-from-db-using-rangy , i have created a js-fiddle : http://jsfiddle.net/janinishant10/wH9Ec/6/ – Nishant Jani Jan 21 '13 at 12:08
  • 1
    @user1537158: It's on my list. – Tim Down Jan 21 '13 at 12:22
0

It is likely the DOM is different in some way. Be sure that before serializing you didn't modify the selection, for example using the rangy CssClassApplier.

Jorge Con Jota
  • 489
  • 1
  • 6
  • 16