Reputation: 17
i want to asking about what is directory.views.SearchPage for? can i call this function as above? is possibe to call page load?
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);
}
});
Upvotes: 0
Views: 228
Reputation: 1295
From what I understand, you want to initialize, render and then call the "share" function on your main view class on page load. Since jQuery is available, i would go simply with:
var searchPage = new directory.views.SearchPage();
$(document).ready(function(e) {
searchPage.render();
searchPage.search(e);
});
But please note that:
Upvotes: 2