我想问一下 directory.views.SearchPage 的用途是什么?我可以像上面那样调用这个函数吗?可以调用页面加载吗?
directory.views.SearchPage = Backbone.View.extend({
templateLoader: directory.utils.templateLoader,
EmployeeListView: directory.views.EmployeeListView,
initialize: function() {
this.template = _.template(this.templateLoader.get('search-page'));
},
render: function(eventName) {
$(this.el).html(this.template(this.model.toJSON()));
this.listView = new directory.views.EmployeeListView({el: $('ul', this.el), model:this.model});
this.listView.render();
return this;
},
events: {
"keyup .search-key": "search"
},
// Start the search function
search: function(event) {
var key = $('.search-key').val();
this.model.findByName(key);
}
});