Permalink
Browse files

fix Backbone.sync mock logging example

Current example always only created items, because an "id" was not set
on the item. With this addition, items can go through the cycle of
create, update, delete.
  • Loading branch information...
1 parent dba521c commit 853cf29b020801bad2ffea11261d7f0e96310f53 @serkanserttop serkanserttop committed Aug 22, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 index.md
View
@@ -942,8 +942,10 @@ var methodMap = {
In the above example if we wanted to log an event when `.sync()` was called, we could do this:
```javascript
+var id_counter = 1;
Backbone.sync = function(method, model) {
console.log("I've been passed " + method + " with " + JSON.stringify(model));
+ if(method === 'create'){ model.set('id', id_counter++); }
};
```

0 comments on commit 853cf29

Please sign in to comment.