2013-01-17 34 views
17

でビューを空にする以下のコードを実行するとき、私はこの主張を取得する:これはなぜ http://plnkr.co/edit/s3bUw4JFrJvsL690QUMiエンバー不明なエラー:アサーションに失敗しました:inBuffer状態

var App = Ember.Application.create({ 
    Store: DS.Store.extend({ 
    revision: 4, 
    adapter: DS.FixtureAdapter.create() 
    }), 

    Router: Ember.Router.extend({ 
    root: Ember.Route.extend({ 
     index: Ember.Route.extend({ 
     route: "/", 
     connectOutlets: function(router){ 
      var person; 
      person = App.Person.find(657); 
      person.addObserver("isLoaded", function() { 
      return router.get('router.applicationController').connectOutlet("things", person.get("things")); 
      }); 
     } 
     }) 
    }) 
    }), 

    ApplicationController: Em.Controller.extend(), 

    ApplicationView: Em.View.extend({ 
    template: Em.Handlebars.compile("{{outlet}}") 
    }), 

    ThingsController: Em.ArrayController.extend({ 
    thingTypes: (function() { 
     return App.ThingType.find(); 
    }).property() 
    }), 

    ThingsView: Em.View.extend({ 
    template: Em.Handlebars.compile([ 
     '{{#each controller.thingTypes}}', 
     '{{this.name}}', 
     '{{/each}}', 
     '{{#each controller.content}}', 
     '{{this.title}}', 
     '{{/each}}'].join("")) 
    }), 

    //MODELS 
    Person: DS.Model.extend({ 
    things: DS.hasMany('App.Thing', { 
     embedded: true 
    }) 
    }), 

    Thing: DS.Model.extend({ 
    description: DS.attr('string'), 
    thingType: DS.belongsTo("App.ThingType", { 
     embedded: true 
    }), 
    title: (function() { 
     return this.get("thingType.name"); 
    }).property("description") 
    }), 

    ThingType: DS.Model.extend({ 
    name: DS.attr("string") 
    }) 
}); 

App.Person.FIXTURES = [ 
    { 
    id: 657, 
    things: [ 
     { 
     id: 1, 
     description: "Some text", 
     thing_type: { 
      id: 1, 
      name: "type 1" 
     } 
     }, { 
     id: 2, 
     description: "Some text", 
     thing_type: { 
      id: 2, 
      name: "type 2" 
     } 
     } 
    ] 
    } 
]; 

App.ThingType.FIXTURES = [ 
    { 
    id: 1, 
    name: "type 1" 
    }, { 
    id: 2, 
    name: "type 2" 
    }, { 
    id: 3, 
    name: "type 3" 
    } 
]; 

:デモへ

Emptying a view in the inBuffer state is not allowed and should not happen under normal circumstances. Most likely there is a bug in your application. This may be due to excessive property change notifications.

リンクハプニング?

+0

これは新しいルータでも発生します。問題を解決できない:-( – sudhanshu

答えて

0

少し遅れて、私は推測する...しかし、私はそれがここで動作するようになった: http://plnkr.co/edit/hDCT4Qy1h5aE6GjM76qp

は、ロジックを変更が、どこのが

と呼ばれる私はこのようなルーターを変更しませんでした:

Router: Ember.Router.extend({ 
    root: Ember.Route.extend({ 
     index: Ember.Route.extend({ 
     route: "/", 
     connectOutlets: function(router) { 
      var person; 
      router.set('router.applicationController.currentPerson', App.Person.find(657)); 
     } 
     }) 
    }) 
    }) 

そして、ApplicationControllerに作成:

ApplicationController: Em.Controller.extend({ 
    currentPerson: null, 
    currentPersonLoaded: function() { 
     this.connectOutlet("things", this.get("currentPerson.things")); 
    }.observes("currentPerson.isLoaded"), 
    }) 

これはあなたが望んだ出力だが、バグが消えたかどうかは分かりません!

2

フィクスチャからドロップダウンリストのリストをロードしようとしているときに同じエラーが発生しました。

App.FixtureAdapter = DS.FixtureAdapter.extend 
    latency: 200 
    queryFixtures: (records, query, type) -> 
    records.filter (record) -> 
     for key of query 
     continue unless query.hasOwnProperty(key) 
     value = query[key] 
     return false if record[key] isnt value 
     true 

私はおそらく私が最初の待ち時間を設定していなかったことを考え出していません:何それは、固定具アダプタにqueryFixturesをオーバーライドして解決しました。その後、エラーは少し説明的でした。

関連する問題