2013-01-17 10 views
17

ottengo questa affermazione quando viene eseguito il codice qui sotto:Errore brace Uncaught: asserzione non riuscita: Svuotamento una vista nello stato InBuffer

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.

Link Demo: http://plnkr.co/edit/s3bUw4JFrJvsL690QUMi

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" 
    } 
]; 

perché è questo succedendo?

+0

Ciò accade ancora nel nuovo router. Incapace di inchiodare il problema :-( – sudhanshu

risposta

0

un po 'tardi credo ... ma ho avuto a lavorare qui: http://plnkr.co/edit/hDCT4Qy1h5aE6GjM76qp

non ha modificato la logica, ma in cui la sua chiamata

ho modificato il router in questo modo:

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)); 
     } 
     }) 
    }) 
    }) 

e ha creato un'ApplicationController:

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

Non so se questo è l'output desiderato ma il bug è scomparso!

2

Avevo lo stesso errore durante il tentativo di caricare un elenco di valori a discesa da fixture. Che è stato risolto override queryFixtures sull'adattatore apparecchio:

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 

probabilmente non l'avrei capito se non avessi impostato la prima latenza. Quindi l'errore è stato un po 'più descrittivo.

Problemi correlati