vendredi 9 décembre 2016

Parent route's model not being loaded when nested route is refreshed

I have a parent route with a nested route. The parent route's model doesn't get loaded in certain circumstances.

nested index route:

// routes/event/index.js
  actions: {
    reload() {
      this.refresh();
    }
  }

parent route:

// routes/event.js
   model(params) {
     window.console.debug(params);
     return this.store.findRecord('event', params.event_id, { include: ['event-commands'], reload: true });
   },

Initial load of the index route works:

Preparing to transition from '' to 'event.index'
ember.debug.js:55553 Transition #0: application: calling beforeModel hook
ember.debug.js:55553 Transition #0: application: calling deserialize hook
ember.debug.js:55553 Transition #0: application: calling afterModel hook
ember.debug.js:55553 Transition #0: event: calling beforeModel hook
ember.debug.js:55553 Transition #0: event: calling deserialize hook
event.js:8 model Object {event_id: "7"}
ember.debug.js:55556 Attempting transition to loading
ember.debug.js:27012 Intermediate-transitioned into 'loading'
ember.debug.js:55553 Transition #0: event: calling afterModel hook
ember.debug.js:55553 Transition #0: event.index: calling beforeModel hook
ember.debug.js:55553 Transition #0: event.index: calling deserialize hook
ember.debug.js:55553 Transition #0: event.index: calling afterModel hook
ember.debug.js:55553 Transition #0: Resolved all models on destination route; finalizing transition.
ember.debug.js:26879 Transitioned into 'event.index'
ember.debug.js:55553 Transition #0: TRANSITION COMPLETE.

Loading a different nested route, or clicking a refresh button in the page which calls the reload action defined above, results in this:

Starting a refresh transition
ember.debug.js:26950 Preparing to transition from 'event.index' to 'event.index'
ember.debug.js:55553 Transition #1: event.index: calling beforeModel hook
ember.debug.js:55553 Transition #1: event.index: calling deserialize hook
ember.debug.js:55553 Transition #1: event.index: calling afterModel hook
ember.debug.js:55553 Transition #1: Resolved all models on destination route; finalizing transition.
ember.debug.js:26879 Transitioned into 'event.index'
ember.debug.js:55553 Transition #1: TRANSITION COMPLETE.

How do I make refresh load the parent route? Or fix it some other way?




Aucun commentaire:

Enregistrer un commentaire