Here are two models from my application:
var Page = DS.Model.extend({
PageNumber: attr('number'),
Content: attr('string'),
....
});
var Comment = DS.Model.extend({
Page: DS.belongsTo('page'),
Comment: attr('string'),
...
});
The comments are retrieved when the user select the page that he wants to see with the as follows:
retrieveComments: function(selectedPageNumber) {
this.store.find('comment', { page: selectedPageNumber}).then(function(comments){
console.log('comments were retrieved');
});
}
I have a controller and template that need to render the comments for the current page. This controller has a property comments that returns all comments from store for the selected page.
My problem is that this property need to automatically update when the page is changed and another comments are retrieved from the server. Please advice!