Emberjs: transitionToRoute in the same route with different model value

I have an Ember application consisting of 3 routes:

  • router.route('territory', { path: 'localhost/app/territory/:tid' });

  • router.route('aggregator', { path: localhost/app/territory/:tid:/aggregator/:aid' });

  • router.route(territory, { path: 'localhost/app/territory/:tid/aggregator/:aid/item/:iid' });

the transition through transitions is carried out from the territory to the aggregator, from the aggregator to the element and from the element to the subclause. The sub-item uses the same route (third), simply changing the iID value in the route model.

I created an action that allows the user to go to a specific route with some logic and at the end run the command:

 model={ tid: "ttt" aid: "aaa" iid: "iii" } destination = 'item'; //the name of item route controller.transitionToRoute(destination, model); 

If I am in an element’s route and I want to go to another element, the URL will be updated, but not the contents of the page. Obviously, if I refresh the page with the generated URL, the content will refresh.

Where is the problem? in a transition method that is out of date or do I need to use something else?

IMPORTANT: I ​​am using EmberJS - V1.0.0-RC.1

+7
source share
1 answer

Not a mistake - this is a common situation in emberjs, because each route has a model and setupController . The model function is used to asynchronously extract the necessary information from the WS or Data module (this is RSVP.Promise ). Upon completion, the information will be passed to the setupController function, where the specified controller properties related to the type of the current route will be available. Each time I change the value of the path, but not the route, only setupController . In conclusion, in my case, the problem was just a code organization problem.

0
source

All Articles