alekseykulikov / backbone-offline

[Deprecated] Allows your Backbone.js app to work offline
MIT License
720 stars 56 forks source link

error on fetch/pull #45

Open reubano opened 11 years ago

reubano commented 11 years ago

When I run @collection.storage.sync.pull() or @collection.fetch() I get the error TypeError: item.id is undefined. Push works fine and posts to my restapi. Any idea what I'm doing wrong?

reubano commented 11 years ago

Well, the error was with createItem. And the following fixes it

      Sync.prototype.createItem = function(item) {
        // console.log(item)
        if (item.id && !_.include(this.storage.destroyIds.values, item.id.toString())) {
          item.sid = item.id;
          delete item.id;
          return this.collection.items.create(item, {
            local: true
          });
        }
      };

The wierd part is that with the logging on, it spells 'success' with each item being one letter. I don't know why that is.

reubano commented 11 years ago

Another data point.... for ajax queries, the textStatus argument is success on successful calls.

ghost commented 11 years ago

Cool - thanks for the fix of the item.id is undefined bug!