You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing that would be useful is to be able to access meta information on associated objects. Here's an example of a use case:
Let's say that I have a Todo list with a list of Actions. Each Action hasMany Comments. I would like to find out how many comments an action has without loading the association and also find out whether the association has been loaded to determine whether I'm showing a collapsed or expanded comments view.
This would let me have a view that looks like this:
My cool action title!!!
View 3 comments
My cool action title!!
comment 1
comment 2
comment 3
App.Action=DS.Model.extend({comments: DS.hasMany('App.Comment');})App.Comment=DS.Model.extend({body: DS.attr('string');});// Example requesta=App.store.findAll(App.Action);// Response{actions: [{"id":0comment_ids: [123,456,321]}, ...
]// This is what I'd like to be able to doa.comments.isLoaded();// or a.get('comments.isLoaded')=>falsea.comments.count();// or a.get('comments.count')=>3a.get('comments');=>// triggers a load request and returns an array of commentsa.comments.isLoaded();=>true// because the associated objects have been loaded
Hope this makes sense!
The text was updated successfully, but these errors were encountered:
+1, to provide a simple way to be notified when a list of items has been loaded either by callback functions or any binding to a property. This could be applied for associations and modelArrays.
One thing that would be useful is to be able to access meta information on associated objects. Here's an example of a use case:
Let's say that I have a Todo list with a list of Actions. Each Action hasMany Comments. I would like to find out how many comments an action has without loading the association and also find out whether the association has been loaded to determine whether I'm showing a collapsed or expanded comments view.
This would let me have a view that looks like this:
My cool action title!!!
My cool action title!!
comment 1
comment 2
comment 3
Hope this makes sense!
The text was updated successfully, but these errors were encountered: