Hello.
First off, congratulations on V5, I like it a lot.
I am trying to set up a process to get a new page’s title.
I can react to the change, but I can’t get the new title, I get either the previous (index.html) page’s title, or one of the side bars.
app.views.main.router.on('routeChange', function(){
console.log(' - Page changed');
console.log('----->>>>' + $$('.page-current').attr('data-name'));
app.views.main.router.on('pageMounted', function(){
console.log(' - Page mounted');
console.log('----->>>>' + $$('.page-current').attr('data-name'));
console.log('----->>>>' + $$('.title').html());
});
});
/*
Output:
- Page changed
----->>>>home
- Page mounted
----->>>>home
----->>>>Left Panel
*/
Any ideas?
Thank you very much.
twisted_head:
function(){
https://framework7.io/docs/view.html#router-instance-events
Params: newRoute, previousRoute, router
Thank you!
I found out that I can not get the new page’s title because there are several divs with that class, I will use ids for them.
This:
app.views.main.router.on('routeChanged', function(newRoute, previousRoute, router){
console.log('Change!');
console.log('newRoute ' + JSON.stringify(newRoute));
console.log('previousRoute' + JSON.stringify(previousRoute));
});
/*
Change!
newRoute {"query":{},"params":{},"url":"/about/","path":"/about/","route":{"path":"/about/","url":"./pages/about.html"}}
previousRoute{"query":{},"params":{},"url":"/ls/","path":"/ls/","route":{"path":"(.*)","url":"./pages/404.html"}}
*/
For some reason the index.html is seen as 404.html, when I go back or leave that page that is the route I get. But I get the path ‘ls’ which is the base path, so I can figure out the rest I guess.
Again, thank you so much.
Apparently route with /ls/
path must be specified in routes as well
Brilliant!
I see what was going on.
Thank you so much, this is basically what I needed.
Best regards.