You should initialize datepicker e.g. in render
method, and datepicker will open automatically on button click, so you won't need calClicked
at all.
var page1View = Backbone.View.extend({
// Setting the view's template property using the Underscore template method
template: _.template(tmpl_page1View),
// View constructor
initialize: function() {
self = this;
},
// View Event Handlers
events: {
"click #page2": "clickedPage2",
"click #cal":"calClicked"
},
// Renders the view's template to the UI
render: function() {
this.$el.html(this.template({data: this.templateData}));
// init datepicker
this.$("#fromDate").datepicker({
showOn: "button",
buttonImage: "img/calendar.gif",
buttonImageOnly: true
});
// Maintains chainability
return this;
},
clickedPage2:function(){
window.location.href = "#page2"
}
});
return page1View;
});