Reputation: 65
Restating the problem:
Might be best to show how I got here: http://jsbin.com/qizog/114/edit?html,js,output
How can I both keep the binding and have the checkbox send an action to SomethingController?
Below was some attempt at seeing if I could observe the toRender data itself - outside of anything happening in the template. Maybe not the solution but I'm grasping at straws here.
I'd appreciate any help on this complicated problem. Thanks in advance!
Previous post:
I am trying to detect when there is a change to the number of App.File records that have the toRender attribute = true.
I wanted to set a controller property to a filter and then use observe. Is this just the wrong trail to go down? Does anyone have a better idea for doing this?
As a result of the following, am getting a "Uncaught TypeError: object is not a function" error. (ember-data.js:7325).
App.File = DS.Model.extend({
name: DS.attr('string'),
toRender: DS.attr('boolean'),
});
App.MyController = Ember.ArrayController.extend({
toRender: null,
init: function () {
this.set('toRender', this.store.filter(App.File, {
toRender: true
}));
},
toRenderChanged: function () {
console.log('toRender has changed!');
}.observes('toRender')
}
Upvotes: 1
Views: 649
Reputation: 6709
Because this is an Ember.ArrayController
you will need to use @each
to observe changes on any of its objects. So you'd change
toRenderChanged: function () {
console.log('toRender has changed!');
}.observes('toRender')
to
toRenderChanged: function () {
console.log('toRender has changed!');
}.observes('@each.toRender')
No need for the filter
Upvotes: 0