[英]How set router in backbone?
In my app i've a menu and any option is mapped with uri in a router. 在我的应用程序中,我有一个菜单,所有选项均与uri在路由器中映射。 In the view of log page there are two optinos:one to log-in and another to open a new view to sign-up,the prolem is:when i go to the sign-up view the url remain the same as previous log page.This is normal because there are no map in the route but it's correct?
在日志页面的视图中有两个optino:一个用于登录,另一个用于打开新视图进行注册,问题是:当我进入注册视图时,URL保持与以前的日志页面相同这是正常的,因为路线中没有地图,但这是正确的吗?
The view log-page: 查看日志页面:
var LoginView = Backbone.View.extend({
template: Handlebars.compile(template),
events: {
"click .log_in":"log_in",
"click .sign_up": "signUp_manual"
},
initialize: function() {this.render();},
render: function() {
var html =this.template();
$('#pagina').html(this.$el.html(html));//appendo ad el);
return this;
},
signUp_manual: function(){
console.log("signup");
new SignupView();
},
log_in:function(){
console.log("login");
var username = this.$("#login-username").val();
var password = this.$("#login-password").val();
Parse.User.logIn(username, password, {
success: function(user) {
console.log("login riuscito");
window.location='index.html' ;//METTERE UNA NEW APPVIEW MA DA ERRORE!!!
},
error: function(user, error) {
console.log("login non riuscito");
}
});
}
//inserire funzione per log-in
});
return LoginView;
});
您可以这样离开,但是如果您想在有人单击注册视图时更新URL,则可以这样做:
Backbone.history.navigate('mydomain.com/signup', {trigger: true});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.