-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
linkTo helper does not notice changing ember-data id #2241
Comments
Think this is a dup of #2181 |
@rlivsey, looks like it. |
mhh it states there that: "This will of course not handle the case when the actual attribute, like an id, changes, but it will help in most cases. Most of the time you use id and most of the time id does not change." but i'm exactly talking about the id here |
@Goltergaul this is a bit different case. In your situation I would do something like: {{if playlist.id}}
{{#linkTo "playlist" playlist}}{{playlist.name}}{{/linkTo}}
{{/if}} The problem is that you should not even generate a link if you don't have id, because it will just fail without an id. |
@Goltergaul actually, I see what you mean now - you may want to still render the link, just with Unfortunately, at this point it's rather hard to fix this in Emebr. In order to generate a path for Despite the technical problems behind this, I strongly believe that this should be solved by Ember, not the end user. My proposal would be to always check for an id in addition to a param itself in #2181. It will handle most of the cases and leave us only with non id attributes (for example TravisCI uses App.RepositoryRoute = Ember.Route.extend({
serializeProperties: ['slug']
}); or by making it easier to reload link in the template. Helper like |
@drogus the workaround with an if is a good idea thanks. I agree with you on the rest |
when you have a linkTo helper and pass it an ember-data model that is newly created (has no id) then it links to /route_name/null. so far so good. when i now persist the model to the database the model gets an id. but the link does not notice the new id and stays the same.
this is how i persist the model:
and this is the template:
The text was updated successfully, but these errors were encountered: