How to create a link without preloading the model?

Right now we are building our links as follows:

<a {{action showComment comment href=true}}>Show</a> 

This creates a link that looks like /comments/45 .

Unfortunately, this only works when we preload a comment, even if we already have a comment identifier. Can I comment without preloading?

Something that might look like:

 <a {{action showComment comment_id href=true}}>Show</a> 
+6
source share
1 answer

What is the real question here? This is not entirely clear to me.

So your current handler looks like this:

 showComment : function(comment){ //do your stuff with the model } 

Now your desired solution might 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 } 

Will this work in your case? Or did you intend for something else?


UPDATE: OP would like to have all the data processing in the route. Your route should handle the "showCommentById" action that I suggested earlier:

 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, in fact, you can decide where to handle the actions in your application.

+2
source

All Articles