mutation-summary icon indicating copy to clipboard operation
mutation-summary copied to clipboard

Ability to request full page refresh

Open spoco2 opened this issue 9 years ago • 4 comments

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
    };

spoco2 avatar Dec 22 '15 22:12 spoco2

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
    };

spoco2 avatar Dec 23 '15 00:12 spoco2

did you ever figure this out?

jiangts avatar Feb 11 '16 09:02 jiangts

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.

sheriff91 avatar Aug 15 '16 14:08 sheriff91

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__

haseebeqx avatar Feb 14 '20 09:02 haseebeqx