Permalink
Browse files

Merge pull request #161 from serkanserttop/master

Backbone.sync mock example fix
  • Loading branch information...
2 parents dba521c + 853cf29 commit ca3900482b453388c6d89197d1338274bf594666 @addyosmani 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 ca39004

Please sign in to comment.