Last active
December 11, 2015 19:18
-
-
Save gugahoi/4647412 to your computer and use it in GitHub Desktop.
keyUp filter function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Filter = Ember.TextField.extend({ | |
keyUp: function() { | |
var array = App.Movies.FIXTURES; | |
for (var i = array.length - 1; i >= 0; i--) { | |
var name = array[i].name, | |
id = array[i].id, | |
movie = App.Movies.find(id); | |
if(name.toLowerCase().indexOf(this.get('value')) !== -1){ | |
movie.set('isHidden', false); | |
} else { | |
movie.set('isHidden', true); | |
} | |
} | |
} | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/x-handlebars" data-template-name="_movieMenu"> | |
{{view App.Filter class="span12" placeholder="Filter"}} | |
<ul class="unstyled well"> | |
{{#each movie in controller}} | |
<li {{bindAttr class="movie.isHidden:hidden:visible"}}> | |
{{#linkTo "movie" movie}} | |
{{ movie.name }} | |
{{/linkTo}} | |
</li> | |
{{/each}} | |
</ul> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment