How to change automatically to last view visited in dojo?

时间:2019-04-08 12:50:58

标签: javascript dojo

i have a problem in my dojo code.

What I want: When my client gives an F5 in the page, that it is redirected to the last view visited

My Problem: My views are created only when I click on them in the layout I want to be created dynamically, ie I would have to create the views before and give a TransitionPerform so it automatically goes to the view, but how do I do this?

settings_processData: function(layout_data, username) {
        var strclient;
        strclient = localStorage.getItem('lastview');
        var id;
        if(strclient && typeof strclient === 'string' && strclient.startsWith('app_plant_PlantView_')){
            id = strclient.replace("app_plant_PlantView_", "");
            console.log(strclient);
            console.log(id);    
        }
        console.log(layout_data);
        /*if(id.length > 0){
            var lastview = new PlantView({
                id: strclient,

            })
            performTransition("#"+strclient, 1, "slide");
        }
        */  

        var layout_store = new Memory({data:layout_data});
        layout_store.query({}, {
            sort: [{attribute: "name"}]
        }).forEach(lang.hitch(this, function(item) {
            new ListItem({
                label : item.name,
                layoutData: item, //persists locally the layout
                "iconPos": "38,593,36,30",
                moveTo: "#",
                onClick: function() {
                    console.log(item);
                    if (this.moveTo === "#") {
                        var view = new PlantView({
                            id: "app_plant_PlantView_" + item.id,
                            layoutData: this.layoutData
                        }, domConstruct.create("DIV", null, document.body));
                        view.startup();
                        this.moveTo = "#" + view.id;
                        console.log(view);
                        localStorage.setItem('lastview', view.id);
                    }               
                },
            }, domConstruct.create("li",{}, this.ul.domNode))
            .startup(); 
        }));

0 个答案:

没有答案