mardi 21 mars 2023

In Ember, in resetController function, why is transition undefined sometimes?

I am using Ember 3.16

I have an Ember application which has multiple routes.

For one of the routes, let's call it route x, I need it to reset only when it leaves the page. So I use resetController and only reset when isExiting and transition is true, like below:

resetController(controller, isExiting, transition) { if (isExiting && transition) {...} },

I need to check transition because I have pagination so when it goes to the next page, it refreshes the route.

The problem is when I navigate to some of the routes, transition is undefined so when I come back to route x, it does not reset. I need it to reset every time we go to a different page.

I do not understand why transition is defined when navigating to some routes and not others, anyone have any insights?

I tried comparing the routes where transition is defined to the ones they are not defined. I could not find a pattern. For some of the differences I even tried making them similar to see if it fixes it. It did not work.

I used Ember Inspector to see the routes change, and the routes always change. When transition is defined or undefined, I see routes changing.




Aucun commentaire:

Enregistrer un commentaire