Javascript ember.js Uncaught TypeError:对象数据大小没有方法';过渡到';

Javascript ember.js Uncaught TypeError:对象数据大小没有方法';过渡到';,javascript,facebook,facebook-graph-api,ember.js,Javascript,Facebook,Facebook Graph Api,Ember.js,我对ember非常陌生,并试图通过facebook实现身份验证 我正在使用图书馆连接facebook。一旦身份验证成功,我想转换到其他路径,例如“/index”。此库在mixin中创建App.FBUser对象,该对象由facebook响应填充。博客上说: App = Ember.Application.creatWithMixins(Ember.Facebook, { updateFBUser: function() { this._super(); // we are ca

我对ember非常陌生,并试图通过facebook实现身份验证

我正在使用图书馆连接facebook。一旦身份验证成功,我想转换到其他路径,例如“/index”。此库在mixin中创建App.FBUser对象,该对象由facebook响应填充。博客上说:

App = Ember.Application.creatWithMixins(Ember.Facebook, {
  updateFBUser: function() {
    this._super();
    // we are calling super to let the addon
    // do it's work but at the same time we get
    // notified that something happened, so do at this
    // point your transition
  }
});
每当用户更改(登录、注销、应用程序授权等)时,就会调用updateBuser方法,更新应用程序上的app.FBUser对象。你可以用这个绑定做任何你想做的事情,观察它,把它放到DOM中,随便什么

更新:

在我的LoginController中添加以下观察者,我能够捕获App.FBUser更新事件(它是在收到FB的响应后更新的;如博客所示)。 从这个观察者方法中,当我尝试“转换到”我的索引路径时,我得到以下错误 未捕获类型错误:对象数据大小没有方法“转换到”。下面是代码

App.LoginController = Ember.Controller.extend({
onSuccess: (function(){
    var self = this;
    /*
        //tried all these method to redirect but error is the same
        var attemptedTransition = this.get('attemptedTransition');
        attemptedTransition.retry();
     */
     /*
    //tried all these method to redirect but error is the same
    var router = this.get('target.router');
    router.transitionTo('index');
    */
    
    //tried all these method to redirect but error is the same
    this.transitionToRoute('index');
}).observes('App.FBUser')
});
索引路线

App.AuthenticatedRoute = Ember.Route.extend({ 
 beforeModel: function(transition){
 var self = this;
 if(!App.FBUser){
  self.redirectToLogin(transition);
 }
},

redirectToLogin: function(transition){
var loginController = this.controllerFor('login');
loginController.set('attemptedTransition', transition);
this.transitionTo('login');
  }
});
我没办法控制住它

非常感谢您的帮助。谢谢

如何在Route.beforeModel()钩子中访问此对象

根据您谈论的模型挂钩之前的路线,您可以这样做:

App.SomeRoute = Ember.Route.extend({
  beforeModel: function(transition) {
    if (!Ember.isNone(App.FBUser)) {
      // calling 'transitionTo' aborts the transition, redirects to 'index'
      this.transitionTo('index');
    }
  }
});
更新以回应您最后的评论 您正在使用的插件有点过时,应用程序中针对mixin的建议实现方法将无法与当前版本的ember一起使用:

App = Ember.Application.create(Ember.Facebook)
App.set('appId', 'yourfacebookappid');
从ember的1.0.0-rc3版开始,您应该这样做:

App = Ember.Application.creatWithMixins(Ember.Facebook);
App.set('appId', 'yourfacebookappid');
之后,您应该能够访问上面提到的
App.FBUser
对象

更新2 如果您希望能够在某些事件发生时收到通知,如
登录
注销
等。您应该(正如插件作者在其博客文章中所述)覆盖
更新Buser
方法,并在其中进行转换

由于插件是通过我们
应用程序
命名空间中的mixin提供的,因此您应该能够执行以下操作:

App = Ember.Application.creatWithMixins(Ember.Facebook, {
  updateFBUser: function() {
    this._super();
    // we are calling super to let the addon
    // do it's work but at the same time we get
    // notified that something happened, so do at this
    // point your transition
  }
});
希望有帮助。

根据添加

致:


解决了问题。

我已经更新了帖子,解释了我想要实现的确切场景。请指导。我已经将其更新为使用App=Ember.Application.creatWithMixins(Ember.Facebook);。我能够与FB沟通并更新我的模板。我想要实现的是,当我收到来自FBVEPixel的成功响应时,重定向到其他路径(“索引”)。对不起,我是个令人讨厌的哑巴。我补充了更多的细节。请帮帮我。
attributeBindings: [],
return Ember.FacebookView = Ember.View.extend({