vendredi 26 décembre 2014

Implementation of Site-wide arrayController in Ember

I have been looking to a solution to this for about a week now with no luck. We have an ember application which has a sidebar that is present on all routes which displays a list of user posts. It is important that the posts update in real-time as they are submitted as well as sort with the newest post at the top of the list, which from what I've read will require an array controller. The problem is, I cant find any way (or rather dont understand) to use an array controller and specific model that is not directly referenced to the current route. I have tried rendering the sidebar with the following code in the application route:



Destination.ApplicationRoute = Ember.Route.extend({

model: function(model) {

var self = this;

return new Em.RSVP.Promise(function (resolve, reject) {

new Em.RSVP.hash({

post : self.store.find('post')

}).then(function (results) {

resolve({

post: results.post

});
});
});
},

renderTemplate: function(controller, model) {

this.render();

this.render('sidebars/postBar', {

outlet: 'postbar',

into: 'application',

controller: 'posts',

model: 'post'

});
}


Then I have the following code for my array controller



Destination.PostsController = Ember.ArrayController.extend({

itemController: 'post',

sortProperties: ['id'],

sortAscending: false

});


However this doesnt work at all and I'm having trouble finding any examples of how to accomplish this.





Aucun commentaire:

Enregistrer un commentaire