Santosh
Santosh

Reputation: 3837

Return current page on load framework7

I want to return current page on load. If the user directly lands on that page it should redirect to home page.

Below script works on 'pageInit' but i want to get the current page on load. if the user directly lands on 'email-confirmation' it should redirect to home page.

$(document).on('pageInit', function(e){ // it is working on pageInit but I need it in load.
    var page = e.detail.page;
    console.log(page.name);
    if(page.name=="email-confirmation") {
        mainView.router.loadPage('dashboard.html');//home page              
    }           

})

Any help will be greatly appreciated. Thank.

Upvotes: 0

Views: 1364

Answers (2)

Santosh
Santosh

Reputation: 3837

I came up with the vanila javascript code to achieve my need. But request to use preroute as suggested by @Djiggy.

    var data_attrs = [];
        var data_attr = "";
        $("body").each(function(){
            $(this).find(".page").each(function(){
                attr_value =  $(this).attr('data-page');
                data_attrs.push(attr_value) // returns dashboard and email-confirmation
            });
        });
        console.log(data_attrs);
        if(attr_value[1]=="email-confirmation") {
            mainView.router.loadPage('dashboard.html');//home page              
        }   

Upvotes: 0

Djiggy
Djiggy

Reputation: 602

You could use preroute to manage redirection page, no ?

Upvotes: 1

Related Questions