Amber routing - a model hook not called upon page refresh

I am trying to use nested routing to render a collection. After rendering the collection, clicking on an element (using a link) displays that particular element in a socket. All of this works great so far.

I had a problem when refreshing the page does not cause the "model" of my sub-resource to bind.

From the Ember website at http://emberjs.com/guides/routing/specifying-a-routes-model/ :

What happens if a user visits your application directly with a URL that contains a dynamic segment? For example, they can reload or send the link to a friend who clicks on it. In this case, because we are starting the application from scratch, the JavaScript model object was displayed; all we have is an id from the url.

Fortunately, Ember will extract any dynamic segments from the url for you and pass them as a hash to the model hook as the first argument

Here is my code:

Admin.Workqueues.App.Router.map(function () {
  this.resource('delinquencies', function () {
    this.resource('delinquency', {
      path: '/:id'
    });
  });
});

Admin.Workqueues.App.DelinquenciesRoute = Ember.Route.extend({
  model: function () {
    // Does XHR here and fetches a collection of items to render.
    // Returns a promise
  }
});

Admin.Workqueues.App.DelinquencyRoute = Ember.Route.extend({
  model: function (params) {
    debugger; // This doesn't get called
  }
});

Thus, with this code, the entire collection is displayed in / delinquencies . Clicking on an element opens the delay object in / delinquencies / 3 , but now updating the page does not cause the model of the extension route to be linked.

I'm not sure what I am missing. Any ideas? If that matters, I use:

: 1.2.0

Ember: 1.0.0-beta.7 + canary.f482da04

: 1.1.1

+4
1

, .

Admin.Workqueues.App.Router.map(function () {
  this.resource('delinquencies', function () {});
  this.resource('delinquency', { path: '/:delinquency_id' });
});

, , , - , .

DelinquencyRoute - :

return this.store.find('delinquency', params.delinquency_id);

: http://emberjs.com/guides/routing/defining-your-routes/ ( )

+2

Source: https://habr.com/ru/post/1533393/


All Articles