我想让加载的页面运行“搜索”功能,但我在 self.search(event) 中收到错误消息。请在那里提供一些帮助,我如何页面加载调用搜索功能?
directory.views.SearchPage = Backbone.View.extend({
templateLoader: directory.utils.templateLoader,
initialize: function() {
this.template = _.template(this.templateLoader.get('search-page'));
this.render();
var keyword = '_firstkey';
$(document).ready(function (event) {
self.search(event); //Uncaught TypeError: Object [object global] has no method 'search'##
})
},
render: function(eventName) {
$(this.el).html(this.template(this.model.toJSON()));
this.listView = new directory.views.EmployeeListView({el: $('.scroll', this.el), model: this.model});
this.listView.render();
return this;
},
events: {
"keyup .search-key": "search"
},
search: function(event) {
var key = $('.search-key').val();
this.model.findByName(key);
return false;
},
});