ember.js - Ember: ArrayController computed property based on array item properties -


i have arraycontoller on want set boolean property based on properties of contents.

plain-language description of logic:

if array contains any items property of isretired equal true, set retiredshoes property of arraycontroller true, otherwise, set arraycontroller retiredshoes property false.

it seems should simple matter, haven't found solution anywhere, , i'm still pretty new @ this.

i'll put jsfiddle if necessary.

here controllers array , object:

app.applicationcontroller = ember.arraycontroller.extend({     sortproperties: ['title'],     itemcontroller: 'shoe',     retiredshoes: function() {         //how compute sucker?     } });  app.shoecontroller = ember.objectcontroller.extend({     needs: ['application'],     actions: {         delete: function() {             var shoe = this.get('model'),                 runs = shoe.get('runs');             shoe.deleterecord();             shoe.save();         },         toggleretired: function() {             var shoe = this.get('model');             shoe.toggleproperty('isretired');             shoe.save();         }     } }); 

off top of head, without jsbin. if there's problem/bug, drop me comment , i'll on again.

app.applicationcontroller = ember.arraycontroller.extend({     retiredshoes: function() {         return this.get("model").isany("isretired", true);     }.property("model.@each.isretired") }); 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -