Is there a way to navigate to a different page when a specific event is triggered in a View using Backbone?
events: {
'click .btn': 'signin'
},
render: function() {
tmp = this.template();
this.$el.html(tmp);
},
signin: function() {
var logi = document.forms['signin']['name'].value;
var mail = document.forms['signin']['email'].value;
var passwd = document.forms['signin']['pass'].value;
var hash = CryptoJS.SHA256(passwd).toString(CryptoJS.enc.Hex);
var tkn = Math.random(9) * 123123123;
_this.navigate('#', true);
var user = new User({
'login': logi,
'email': mail,
'pass': hash,
'token': tkn.toString(),
'recovery': null,
'img': 'default.png'
});
//var user = new User({ 'user': logi, 'pass': hash });
user.save({
success: function(res) {
alert(res.res);
},
error: function(res) {
alert(res.res);
},
wait: true
});
I have tried this code but it doesn't seem to be working as expected. Can someone assist me in figuring out what's wrong?
The crucial part of the code is _this.navigate('#', true)
.