Search code examples
meteoriron-router

maintaining the data context with a modal and Iron Router?


I'm rendering a modal with iron router, but want to maintain the current data context for whatever page the modal is on top of, is there a way to have it trigger an action but not kill any current subs / data context ?

Router.route('/box', {
  name: 'box',
  controller: 'AppController',
  action: function () {
    this.render('box', { to: 'modal' });
    $('.coverall').fadeIn(function() {
      $('.contain').addClass('blur');
    });
  }
});

Solution

  • So all round this seems to be an unsolvable issue in iron router, as it will always destroy the data context and end subscriptions when navigating to a new route.

    The only viable solution is to really not use Iron Router, substitute it for something like flow router, and manage subscriptions and data context in template level subscriptions.