1

If I haven't saved my Backbone Model to local storage (via Backbone.LocalStorage adapter) using the save() method, how come fetch() returns a success callback? Shouldn't it return an error or some other indication that the model is not in fact in local storage?

My model:

 var User = Backbone.Model.extend({

    initialize: function(){
    },

    localStorage: new Backbone.LocalStorage("User"),

    defaults: { 
        HANDLE: '',
        EMAIL: '',
        UUID: '',
        USERPIC: '',
        TOKENLOGIN: '',
        SIGNUPSTATUS: ''
    },
});

app.User = new User();

And later, when I fetch it:

app.User.fetch({success:this.userFetchSuccess, error:this.userFetchError});

The callback I get every time is the success callback. Can't imagine why!

Update: Looks like the localStorage adapter may not work properly with Models. See this and this.

Community
  • 1
  • 1
Gabe M
  • 61
  • 2
  • 7
  • Another Update: If I follow the instructions here... https://github.com/jeromegn/Backbone.localStorage/issues/56 ... the adapter uses the error callback instead! Perfect. Have spent quite a bit of time on this - hopefully it saves somebody else some agony. – Gabe M Sep 29 '13 at 23:29

0 Answers0