Skip to content

Instantly share code, notes, and snippets.

@darthdeus
Forked from anonymous/posts_controller.js
Created December 14, 2012 20:52
Show Gist options
  • Save darthdeus/4288555 to your computer and use it in GitHub Desktop.
Save darthdeus/4288555 to your computer and use it in GitHub Desktop.
Scvrush.PostsController = Em.ArrayController.extend({
query: null,
updatePosts: _.throttle(function(value) {
var posts;
if (this.get("query") === "") {
posts = Scvrush.get("store").find(Scvrush.Post);
} else {
posts = Scvrush.get("store").find(Scvrush.Post, { query: this.get("query") });
}
this.set("content", posts);
}, 1000),
queryChanged: function(value) {
this.updatePosts()
}.observes("query")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment