Hello,
after i click on “li a” call a ajax.
After Ajax success i need to redirect to another page:
example:
methods:
adminInfo: function () {
const self = this;
this.$f7.request({
type:'POST',
headers: {'Authorization': 'Bearer '+localStorage.accessTokenAPI+''},
data: {},
url: localStorage.ServerURL+"/api/admin_info",
success:function(response){
var udata = JSON.parse(response)
localStorage.setItem('admin_id', udata['data'][0]['user_id']);
// NEED TO REDIRECT at this point
var mainView = app.view.main;
mainView.router.navigate({ name: 'about' });
},
error: function(xhr) { // if error occured
console.log('error');
self.$$("#box_error").removeClass("display-none")
}
});
}
mainView.router.navigate('about');
i have error:
mainView is not defined
did you declare first mainView?
var mainView = app.view.main;
if yes, then try
self.$app.view.main.router.navigate
view => viewS
and
self.$app.views.main.router.navigate => self.$app.views.current.router.navigate
where declare “var mainView” ?
have error with this -> self.$app.view.main.router.navigate
Uncaught TypeError: Cannot read property ‘main’ of undefined
var mainView = app.views.main; -> have error on main is not defined
Shastox is right; change:
var mainView = app.view.main;
to:
var mainView = app.views.main;
In fact, there is an app.view
, but you need to use app.views
in this case.
Replace
var mainView = app.view.main;
mainView.router.navigate({ name: 'about' });
in your code with this:
self.$f7.views.main.router.navigate({ name: 'about' });
// or if it is inside main view then just
// self.$f7router.navigate({ name: 'about' });
self.$f7router.navigate({ name: ‘home’ });
it’s work 
Many thanks
1 Like