Skip to content

Commit

Permalink
Ember+Require app: Apply the fix from Ember app for showing selected …
Browse files Browse the repository at this point in the history
…filter in the filter bar. Fixes #220
  • Loading branch information
sindresorhus committed Aug 2, 2012
1 parent a7a4d9c commit 6da7ad5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ul id="filters">
<li>
<a {{action showAll href=true}}>All</a>
<a {{action showAll href=true}} {{bindAttr class="view.isAll:selected"}}>All</a>
</li>
<li>
<a {{action showActive href=true}}>Active</a>
<a {{action showActive href=true}} {{bindAttr class="view.isActive:selected"}}>Active</a>
</li>
<li>
<a {{action showCompleted href=true}}>Completed</a>
<a {{action showCompleted href=true}} {{bindAttr class="view.isCompleted:selected"}}>Completed</a>
</li>
</ul>
14 changes: 12 additions & 2 deletions dependency-examples/emberjs_require/js/app/views/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ define('app/views/filters', [
*/
function( filters_html ) {
return Ember.View.extend({
template: Ember.Handlebars.compile( filters_html )
})
template: Ember.Handlebars.compile( filters_html ),
filterBinding: 'controller.namespace.entriesController.filterBy',
isAll: function() {
return Ember.empty( this.get('filter') );
}.property( 'filter' ),
isActive: function() {
return this.get('filter') === 'active';
}.property('filter'),
isCompleted: function() {
return this.get('filter') === 'completed';
}.property('filter')
});
}
);

0 comments on commit 6da7ad5

Please sign in to comment.