Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

transitionTo('route', context) passes context base route, not to the route requested

I am working on an Ember app where I wish a button click to transition to a new route passing an object as the context for that route.

The problem is, no matter how I try and pass that context, it is always lost by the time I get to the route I am transitioning to.

Investigating (http://jsfiddle.net/fxbXM/2/) it seems that the the context is passed to the first route the router hits as it works to the requested route. (See the output of the connectOutlets function from each route level)

This seems to confirm what I thought I had found when debugging my actual app: in the triggerSetupContext function of Ember there are three enterStates: [Router, 'root', 'create'] and there are three contexts: [myObject, null, null]

If the contexts were in the opposite order then I would get what I wanted where I wanted it!

Am I making some fundamental error in the way i'm passing the object as a context? Should I be using another approach?

like image 660
Matt Turner Avatar asked Aug 21 '12 21:08

Matt Turner


1 Answers

A bit tricky to realize what does'nt work... while debugging, I found this: in routers, only states with dynamic segments have a context, so in the create route, I added ":widget_id", and it seems to work. see http://jsfiddle.net/Sly7/EqyUa/

It seems that if you don't have any dynamic segment in your route, you can't pass a context to it. It would be great if I can have confirmation of that...

Update

Searching on github repo, I found this issue: #1118. In the last comment, Yehuda explain why this does not make sense to pass a context to connectOutlets without dynamic segment.

like image 163
sly7_7 Avatar answered Nov 01 '22 12:11

sly7_7