vendredi 26 août 2016

Ember - abort the route and reload the route with same model

In my ember app, when the user clicks the Back button of browser,I need to stop the transition (whereever it might take me as per Ember history) and reload the same url with same model. Have tried the below code, but doesnt seem to work:

search-route.js

var route = Ember.route.extend({
   actions:{
      willTransition: function(transition){
         if(this.controller.get('order') === 1){
             transition.abort();
             this.transitionTo('search',model)
         }
      }
    }
})

This doesnt seem to work and gives error about query params. So, i looked for what is there in transition object. Saw that as soon as I enter this code, the object transition contains prop queryParams but with the old values, not the current URL one. But there is another prop - transition.intent.preTransitionState.fullQueryParams which contains the current URL query params. Would that be used here somehow.

I looked for solutions and someone also suggested to put in this.refresh(), but also didn't work.




Aucun commentaire:

Enregistrer un commentaire