mercredi 2 septembre 2015

EmberJS redirect() works strange

I have routes:

this.route('deals', function () {
    this.route('order', {path: ":id"});
});

In "deals" route I do this:

redirect(model, transition){
    if(transition.targetName != 'deals.order'){
      var order = model.orders.objectAt(0);

      return this.transitionTo('deals.order', order);
    }else{
      return this._super(model, transition);
    }
  },

It works fine if I open: http://localhost:4200/deals/1, but if then I go to any other route and then go to /deals with menu, it works such way:

Preparing to transition from 'deals.order' to ' settings.index' //any other route
Transitioned into 'settings.index' //here everything is ok still and next I click menu to go to "deals" route.

Preparing to transition from 'settings.index' to ' deals.index'

And next transitions go with no pouses and I absolutely have no idea why:

Transitioned into 'deals.order' (it goes with orders ID)
Preparing to transition from 'deals.order' to ' deals.index' //why???
Transitioned into 'deals.index' //why???

I even have no idea how to debug it!




Aucun commentaire:

Enregistrer un commentaire