Created
June 15, 2013 05:33
-
-
Save shohey1226/5787042 to your computer and use it in GitHub Desktop.
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.views.HomeView = Backbone.View.extend({ | |
initialize: function () { | |
this.searchResults = new app.models.EmployeeCollection(); | |
this.searchresultsView = new app.views.EmployeeListView({model: this.searchResults}); | |
}, | |
render: function () { | |
this.$el.html(this.template()); | |
$('.scroller', this.el).append(this.searchresultsView.render().el); | |
return this; | |
}, | |
events: { | |
"keyup .search-key": "search", | |
"keypress .search-key": "onkeypress" | |
}, | |
search: function (event) { | |
var key = $('.search-key').val(); | |
this.searchResults.fetch({reset: true, data: {name: key}}); | |
}, | |
onkeypress: function (event) { | |
if (event.keyCode === 13) { // enter key pressed | |
event.preventDefault(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment