New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router: accessing serialized objects from parent dynamic route segments #1334
Comments
An example of this from rails:
This would be slightly different for ember. I would expect to get back |
Related to this, I've found I sometimes need access to parent routes deserialized content in deserialize of a nested route. For example: http://jsfiddle.net/rlivsey/vg4ga/ Here we have In the post action we need to do a request to the server including the project ID and the post ID, but we don't have access to the project from within As all In my app I'm currently getting around this by setting the content property in the parent's |
Just a thought, but generally I would expect the parent route's deserialized content to be available on it's corresponding controller is one form or another. That's how we access it on our app. I'm not necessarily expecting that to hold true for all apps, but i'm guessing it would for most. |
I also ran into this problem. For example there is two routes:
To obtain model from Of course I can do something like |
@wagenet, as @rlivsey said, |
@leepfrog I'm assuming this doesn't directly apply to the new router. If you still have issues, please file a new ticket. |
FWIW, this is still an issue with the new router. A workaround is to override UPDATE: ugh, I see the problem here - serialize is called when generating a URL, which may not be the current model. And in any case, this mysteriously isn't working for the original use case now that it's morning. Sorry. |
With Routing v2, what looks like the right way to do this is to query the parent route's model parameters in the subroute's model hook using modelFor. App.CommentRoute = Ember.Route.extend({
model: function(params) {
var post = this.modelFor('post');
return App.Comment.find({post_id: post.get('id'), comment_id: params.comment_id});
}
}); |
Creating this issue to open up discussion on the topic...
given a route /:post_id,
a subroute /view,
a subroute /:comment_id
I want the ability to access the relevant post object from
connectOutlets
for the/:comment_id
subroute.I realize that you can simply set the post object on a controller as part of connectOutlets for :post_id, but it seems sort of odd to obtain that object through a controller instead of through the router directly.
This is one option:
I picture
deserialize
being responsible for setting this up for the routes in some way.As a work around, @kselden came up with a good solution that involves using ObjectControllers for url data pieces. See: http://jsfiddle.net/krisselden/uErrd/32/
The text was updated successfully, but these errors were encountered: