lundi 11 janvier 2016

Ember 2.2.0 Nested URL doesn't call model hook when refresh page in child

I've got the following nested url :

  Router.map(function() {
     this.route('orders', function() {
           this.route('order', { path: '/:id' });
     });

   });

Following routes :

   export default Ember.Route.extend({

   model(params) {
       return this.store.findRecord('order', params.id, { reload: true });
     }
   });


   export default Ember.Route.extend({
      model() {
         return this.store.findAll('order', { reload: true });
       }
   });

My route /orders got a controller which does the this.transitionToRoute('orders.order', order) to display detail from a click in an image. My model is given to order detail. It works perfectly.

The controller :

export default Ember.Controller.extend({
     onClick(order) {
        this.transitionTo('orders.order', order);
     }
   }
});

The problems is when I'm in /orders/pk and then I do a page refresh. The model hook of the route 'order' is not called.Then I don't have my model in the order detail page but only the ID.

My question is : How to get my model in the child detail page when I refresh the browser page? Or how to get my model hook called ?

Thanks,

Aucun commentaire:

Enregistrer un commentaire