Ability to request full page refresh
I'm trying to use this library with a version of the TreeMirror to have support staff for our application be able to watch a user.
This is currently working pretty well (if we make our form inputs mirror their values to an attribute on the input as well)... however, invariably, the mirror will get lost at some stage and stop recognising where various changes go ('ouch' errors thrown), and I was hoping that the client watching could just tell the mirror to re-initialise the page, send the whole DOM again.
However, I've tried this a number of ways, and none seem to work (see the commented out bits to see what I've tried):
TreeMirrorClient.prototype.refreshDOM = function(){
var rootId = this.serializeNode(this.target).id;
var children = [];
for (var child = this.target.firstChild; child; child = child.nextSibling)
children.push(this.serializeNode(child, true));
console.log("refreshDOM["+rootId+"] ",children);
//this.mirror.initialize(rootId, children);
this.mirror.applyChanged(children);//,children); //Remove all, add all
};
OK, I'm closer now I think... I needed to clear the known nodes, so it effectively starts afresh. This does make the client send a new whole page refresh, but now, after that, it's not sending any further dom updates:
TreeMirrorClient.prototype.refreshDOM = function(){
this.nextId = 1;
this.knownNodes = new MutationSummary.NodeMap();
var rootId = this.serializeNode(this.target).id;
var children = [];
for (var child = this.target.firstChild; child; child = child.nextSibling)
children.push(this.serializeNode(child, true));
this.mirror.initialize(rootId, children);
// this.mirror.applyChanged(children,children); //Remove all, add all
};
did you ever figure this out?
Please tell me you figured this out? Although I'm assuming you'd just need to do something like a hard refresh (clear everything to do with the summary lib) then start again.
you have to remove the "nodemap id" [MutationSummary.NodeMap.ID_PROP] from all the nodes. By default it will be __mutation_summary_node_map_id__