JavaScript Backbone Hash App #3 – the view

// Search
var SearchButtonView = Backbone.View.extend({
el: ‘.goBtnOutside’,
template: _.template(‘<input type=”submit” id=”searchButton” class=”goButton” alt=”Search” title=”Go” value=”Go”>’),
initialize: function(){
},
render: function() {
return this;
},
events: {
‘click #searchButton’: ‘fireSearch’
},
fireSearch: function(e) {
var searchRequest = $(‘#some-field’).val();
if(searchRequest == ”){
Backbone.history.navigate(“AllAnswers”, true);
}
else{
Backbone.history.navigate(“Search:” + searchRequest, true);
}
}
});
var MakeSearchButton = new SearchButtonView();

Leave a Reply

You must be logged in to post a comment.