Parent route's model do not refresh when it's child route transition back to parent route

Hello. I am trying to" not use" ember data to build a simple demo. parent route: /list child route: /list/:object

when I delete a object in child route, and transition back to parent route(/list), I find out the parent route 's model do not refresh. afterModel and beforeModel hook are also not called. (the page actually do not refresh).

is this normal?

please help me. thanks all .

is there anyone can help me? :joy:

Hi @whynot, can you try to explain your problem in more detail? I think people haven’t been able to help because we don’t understand.

1 Like

thanks. :star_struck:

If your routes are defined like this:

this.route('list', function() {
  this.route('detail', { path: '/detail/:id' });
});

And you go from list.detail to list.index, yes, the list route’s model() hook doesn’t re-run. Because you never left that route, you’re still in it. Another way to say this is, the list route and the list.index route are different things.

You may want to move the data loading of the whole list into the list.index route instead. Then it would indeed reload when you go from list.detail to list.index.

1 Like
this.route('list', function() {
  this.route('index', { path: '/detail' });
  this.route('detail', { path: '/detail/:id' });
});

so I will add a route of index. thank you very much. I will try this.

You already have an index route, it’s created automatically at every level.

It’s not wrong to write it explicitly, but it’s not necessary. Also if you do write it, you will want path: '/' instead.

1 Like

but the model(), after/beforModel are not hooked in “list.index”

Do you mean those hooks aren’t running? They need to be in a file named app/routes/list/index.js.