[SOLVED] F7 V3 how to pass context to popup

I have this code and it works but how can I pass context to the gallery?

       var myPopup = hhApp.popup.create({
            content: SHARED.popTemplate,
            on: {
                open: function (popup) {
                    hhApp.views.create(popup.$el.find('.view'), {
                        url: '/gallery',
                        iosDynamicNavbar:true,
                        stackPages: true
                    });
                },
            }
          });

          
          
          myPopup.open();

Here is my route:

  {
  path: '/gallery',
  url: './gallery/gallery.html',
  on: {
      pageInit: function(e, page){
        GALLERY.galleryPage(page.route.context);
      }
  }
},
var popupView = hhApp.views.create(popup.$el.find('.view'), {
  iosDynamicNavbar:true,
  stackPages: true
});
popupView.router.navigate('/gallery', { context: {/*...*/}, reloadCurrent: true })

Awesome thanks! I had this originally but didn’t have the reloadCurrent.

Well I tried several variations to get this to work and still can’t. I get a page not found but i know router is correct as I can hit it on other pages that I don’t try to pass context. What am I missing?

    var myPopup = hhApp.popup.create({
        content: SHARED.popTemplate,
        on: {
            open: function (popup) {
                var popupView = hhApp.views.create(popup.$el.find('.view'), {
                            iosDynamicNavbar:true,
                            stackPages: true
                 });

                popupView.router.navigate('/gallery', { context: {/*...*/}, reloadCurrent: true })
            },
        }
      });

      
      
      myPopup.open();

Will be good to see live example or JSFiddle with the issue

Thanks, I just added a new route to the popup view.

1 Like

Well I thought I was good unit I tried to load a second page in the popup and the route was not defined so I’m back to trying to get your solution to work. So my code is exactly as above. Here is my SHARED.popTemplate if that helps:

'<div class="popup popup-tablet-fullscreen">'+
      '<div class="view"></div>'+ 
'</div>',

When I console log this, I do see the routes:
console.log(‘popupView.router’, popupView.router);
image

And console.log(‘popupView’, popupView.router.routes); shows the route as well:
image

It just keeps saying page not found. Not sure what else I can test

image

Also this code works just need to pass context:

   var popupView = hhApp.views.create(popup.$el.find('.view'), {
                            url: '/gallery',
                            iosDynamicNavbar:true,
                            stackPages: true
                 });

After the page loaded and said ‘not found’, I went to the console and typed in:

var currentView = hhApp.views.current;
currentView.router.navigate('/gallery', { context: {test: 'it works'}, reloadCurrent: true });

And it worked so it appears to be a timing issue.