I am using backbone.js.
I have a login form and I handle it's submit behaviour in events of login view.
What I have done is when user enters email and password, I have shown it on details view, but my problem is I get ?
character in URL when I click on login button...
So does any one knows about this, please help.
Here is my event handling code in login.js
events:{
'submit form' : 'detailsPage'
},
detailsPage: function(){
console.log("submit event fired");
myApp.usermodel.set({"userName":$("#email").val(),"password":$("#password").val()});
myApp.collection.add(myApp.usermodel);
myApp.usermodel.save();
myApp.details= new myApp.DetailsView();
myApp.details.render(myApp.usermodel.get("userName"), myApp.usermodel.get("password"));
}
In the detailsPage
function, you need to prevent the form from actually submitting, by called the event.preventDefault()
function. That event
object will be passed to detailsPage
as a first parameter.
detailsPage: function (event) {
event.preventDefault();
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.