[Solved] Load another page after login


#1

hello
i have first page login page…
when i do login i put some variable in localstorage as username “is_logged_in” i want if user close app not go to login page go to another page how i can do that …
var $$ = Dom7;

var app = new Framework7({
// App root element
root: ‘#app’,
// App Name
name: ‘example’,
touch: {disableContextMenu: false,},
// App id
id: ‘com.myapp.test’,
// Enable swipe panel
// App routes
routes: routes,
lazy: {
threshold: 50,
sequential: true,
},
panel: {
swipe: ‘left’,
},
on: {
pageInit: function () {
if(localStorage.getItem(“username”) == “is_logged_in”){
mainView.router.load({url:’./pages/category.html’, ignoreCache:true, reloadCurrent:true });
}
}
},
});

ofcourse this function is wrong here mainView.router.load({url:’./pages/category.html’, ignoreCache:true, reloadCurrent:true


#2

thank you i solved:…
if(localStorage.getItem(“username”) == “is_logged_in”){
var mainView= app.views.create(’.view-main’, {
url: ‘/category/’
});
}else {
var mainView = app.views.create(’.view-main’);
}


#3

In v3, I realized this.
{
path: ‘/’,
componentUrl: ‘./views/home.html’,
beforeEnter:function(routeTo, routeFrom, resolve, reject)
{
if(localStorage.getItem(‘islogin’) == null)
{ app.loginScreen.open(’#my-login-screen’); }
resolve();
}
}