Edit: in general, how can I call find () and do something with each element in the result set
How to update elements of a given relationship without breaking the binding? For instance. hasMany somethings model, but only the first 10 are loaded initially, and then I want to replace them with the next 10, etc. for pagination
I can call and add to the base OrderedSet, but this breaks the bindings on my page and everything just disappears.
App.Category = DS.Model.extend({ name: DS.attr('string'), type: DS.attr("string"), parent: DS.belongsTo('App.Category'), children: DS.hasMany('App.Category'), stories: DS.hasMany('App.Story'), }); App.CategoryController = Ember.ObjectController.extend({ page: 1, loadPage: function() { console.log(this.get('stories')) var s = App.Story.find({sid: this.get('id'), count: 12, page: this.get('page')}) this.get('stories').clear() for (var i = 0, len = this.length; i < len; ++i) { this.get('stories').add(s[i]) } }, nextPage: function(event) { this.set('page', this.get('page') + 1) this.loadPage() }, prevPage: function(events) { this.set('page', this.get('page') - 1) this.loadPage() }, breadcrumb: function() { return "" }.property('parent'), sortProperties: ['created'], sortAscending: false, nextEnabled: function() { return true }.property('page'), prevEnabled: function() { if (this.get('page') > 1) { return true } return false }.property('page'), });
source share