I'm new to this, it's the first time I use framework7, I saw the documentation, and I had to use the framework7 router but apparently it does not work, any idea of how I can make it work?
// Initialize app
var myApp = new Framework7();
// If we need to use custom DOM library, let's save it to $$ variable:
var $$ = Dom7;
// Add view
var mainView = myApp.addView('.view-main', {
// Because we want to use dynamic navbar, we need to enable it for this view:
dynamicNavbar: true
});
// Handle Cordova Device Ready Event
$$(document).on('deviceready', function() {
});
// Now we need to run the code that will be executed only for About page.
// Option 1. Using page callback for page (for "about" page in this case) (recommended way):
myApp.onPageInit('about', function (page) {
// Do something here for "about" page
})
// Option 2. Using one 'pageInit' event handler for all pages:
$$(document).on('pageInit', function (e) {
// Get page data from event data
var page = e.detail.page;
if (page.name === 'about') {
// Following code will be executed for page with data-page attribute equal to "about"
myApp.alert('Here comes About page');
}
})
$$(document).on("click", "#glog", function() {
window.plugins.googleplus.login(
{},
function (obj) {
localStorage.setItem('email', obj.email);
myApp.alert(obj.email);
},
function (msg) {
myApp.alert(msg);
}
);
});
// Option 2. Using live 'pageInit' event handlers for each page
$$(document).on('pageInit', '.page[data-page="index"]', function (e) {
if (!localStorage.getItem('email')) {
myApp.alert('go to login');
}
})
$$(document).on('pageInit', '.page[data-page="login"]', function (e) {
mainView.router.load({url:'index.html'});
if (localStorage.getItem('email')) {
mainView.router.loadPage({url:'index.html', ignoreCache:true, reload:true })
}
})
$$(document).on('pageInit', '.page[data-page="logout"]', function (e) {
myApp.alert('go to login');
})
I am using it for the login, as you will see. The alert works well that is the function is entering but the router does not work, it should be clear that it does not show any error in the console, just does nothing. Thank you very much for your help.