Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to request full page refresh #19

Open
spoco2 opened this issue Dec 22, 2015 · 4 comments
Open

Ability to request full page refresh #19

spoco2 opened this issue Dec 22, 2015 · 4 comments

Comments

@spoco2
Copy link

spoco2 commented Dec 22, 2015

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
Copy link
Author

spoco2 commented Dec 23, 2015

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

@jiangts
Copy link

jiangts commented Feb 11, 2016

did you ever figure this out?

@hipkiss91
Copy link

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.

@haseebeqx
Copy link

haseebeqx commented Feb 14, 2020

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__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants