Skip to content

Instantly share code, notes, and snippets.

@eviltrout
Last active December 19, 2015 12:49
Show Gist options
  • Save eviltrout/5957785 to your computer and use it in GitHub Desktop.
Save eviltrout/5957785 to your computer and use it in GitHub Desktop.
It's hard to answer these in a tweet :)
You can't pass arguments to computed properties unless you are creating custom setters, but that's a whole different topic!
What you probably want to do here is use an itemController for each row you are displaying (with the button.)
{{#each thing in things itemController="thing"}}
<button {{bindAttr disabled=thing.disabled}}>button</button>
{{/each}}
// Here I am assuming you have a property, currentRange in the IndexController. The thing
// controller compares the `range` of the 'thing' with the `currentRange` of the index controller.
App.ThingController = Ember.ObjectController.extend({
needs: ['index'],
currentRange: Em.computed.alias('controllers.index.currentRange'),
disabled: function() {
return (this.get('range') === this.get('currentRange'));
}.property('range', 'currentRange')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment