Pergunta

When I transition to a new route, is there any way to store previous state with all the parameters?

Browser back button kinda work so I guess window.history.back() instead of link-to helper would work for me, but I am curious is there any Ember way to save a state and transition to it later?

Thanks

Foi útil?

Solução

Not sure, if this case works for you but I have saved the previous state and then make the transition to that state in a tab menu which needed to save the state for each specific menu.

App.MenuRoute = Em.Route.extend({

  actions: {

    willTransition: function(transition) {
      var handlers = this.router.router.targetHandlerInfos;
      var handler = handlers[handlers.length-1];
      this.controller.set('lastHandler', handler);
    },

    selectMenu: function(value) {

        var handler = this.controllerFor(value).get('lastHandler');
        var routeName = (handler) ? handler.name : value;

        var model;
        if ( handler && handler.isDynamic ) {
          model = handler.context;
        }

        if ( model ) {
          this.transitionTo(routeName, model);
        } else {
          this.transitionTo(routeName);
        }

      }
    }

  }

});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top