How to build a link without preloading the model?
ember.js
Solution
What is the actual question here? This is not quite clear to me.
So your current action handler looks like this:
showComment : function(comment){
//do your stuff with the model
}
Now your desired solution could look like this:
<a {{action showCommentById comment_id href=true}}>Show</a>
And the corresponding handler:
showCommentById : function(commentId){
var comment = App.Comment.findById(commentId); // i assume you have this retrieval method or something like it
this.showComment(comment);
},
showComment : function(comment){
//do your stuff with the model
}
Would this work in your case? Or did you intend something else?
UPDATE: OP would like have all Data Handling in the route Your Route should handle the action "showCommentById" that i did propose before:
App.ArticlesRoute = Ember.Route.extend({
events : {
showCommentById : function(commentId){
var comment = App.Comment.findByIds(commentId); // i assume you have this retrieval
this.transitionTo("root.articles.comment", comment);
}
}
});
So actually you are free to decide where to handle actions in your app.
Problem
Right now, we're building our links like that: ``` <a {{action showComment comment href=true}}>Show</a> ``` That generates a link which looks like `/comments/45`. Unfortunately, that only works when we preload the comment - even though we already have the ID of the comment. Is it possible without preloading the comment? Something that might look like: ``` <a {{action showComment comment_id href=true}}>Show</a> ```