[V2] Custom context


#1

Hi!

I am trying to pass a user_id from one page to another, but I can’t find out how to read the id in the pageInit event. Maybe someone can give me the right hint why this was working in v1.x and what I am doing wrong in v2.

Thanks in advance!

Routing event:

{
        name: 'chat',
        path: '/chat/',
        url: './pages/chat.html',
        on: {
            pageInit: function (event, page) {
                console.log(page.context.user_id);
            }
        }
    }

Opening the new page:

app.router.navigate('/chat/', {
    context: {  user_id: 42 }
});

#2
{
  on:{
    pageInit:function(e,page){
      console.log(page.route.context.user_id);
    }
  }
}

app.router.navigate('path',{
  route:{
    context:{
      user_id:42
    }
  }
});

#3

Thank you, that works like a charm!

Maybe this should be added to the documentation somewhere as the only thing I found was this in Page:

$(document).on('page:init', function (e, page) { 
    console.log(page);
})
...
page.context : Template7 context that was passed for this page when using Template7 pages

#4

how do I get page context in F7 Vue v2? My code is similar to the solution above but page.context is undefined