How can i access click event outside the el
scope.
What i have : HTML :
<div class="right_btn"></div>
<div id="template_loader">
<!-- HTML template goes here which contain form inputs-->
<input type="text" class="forgot_password_email" name="forgot_password_email"/>
</div>
View :
var ForgotPasswordView = Backbone.View.extend({
el: "#template_loader",
initialize: function () {
console.log('Forgot Password View Initialized');
},
render: function () {
blockPage();
var that = this;
$.get(App.baseUrl + 'templates/forgot-password-view.html', function (data) {
template = _.template(data, { });
that.$el.html(template);
unblockPage();
}, 'html');
},
events:{
'click .right_btn':'forgotPasswordSubmit', //Doesn't fire as its outside of el
},
forgotPasswordSubmit: function(e){
alert($(".forgot_password_email").val());
e.preventDefault();
}
});
Ive gone through the following :
Backbone.js views - binding event to element outside of "el"
Howto bind a click event in a Backbone subview
but doesn't really help me get it to work.
How can i get the click event of .right_btn
inside the view. I cannot change the template structure to include the right_btn
inside theel
. Is here anyway to bind the outside element or recognize the click event inside a backbone view itself.