我正在使用backbone.js 来实现一个带有facebook 登录按钮的登录页面。
window.LoginPage = Backbone.View.extend({
initialize:function () {
this.template = _.template(tpl.get('login-page'));
},
render:function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
this.bind("nav", this.nav,this);
this.model.bind("reset", this.render, this);
return this;
},
events:{
"click #login":"login"
},
login:function(){
FB.login(
function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
}
);
} else {
console.log('User cancelled login or did not fully authorize.');
}
},
{ scope: "email" }
);
}
});
这行得通,我可以使用我的 Facebook 应用程序登录。但是登录后我希望触发 FB.event.subscribe 。但我不知道如何用backbone.js 来实现它
FB.Event.subscribe('auth.login', function(response) {
Backbone.history.navigate("#locallist",true)
});