1

Using backfire (backbone.js and firebase.js) im having issues getting my data into the model.

Im trying to populate a model once the user has authenticated (so i know which user to get, duh)

var UserModel = Backbone.Model.extend({
  firebase: '',

  setUser: function(uid){

    this.firebase = new Backfire.Firebase('https://app.firebaseio.com/' + uid);
  }
}); 

Once I have a successful login I create a new model and call setUser with the ID returned from firebase auth (simpleuser:10). Then I call userModel.fetch() which only updates the attributes not the rest of the model.

userModel.fetch(): undefined
userModel.attributes
    Object {0: "simplelogin:10", 1: "Master Blaster", 2: "Joe Blow", 3: ..."}

I cannot call .get('title') //should be related to element '1' above.

Something is wrong somewhere, I didnt set the data initially using Backfire.js.

Suggestions on how to fix this?

Thanks everyone

EDIT Seems the way im storing my data in firebase will cause lots of issues. Im nesting lots of data. That needs to be resolved first. SIGH

4

0 回答 0