Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 853cf29b020801bad2ffea11261d7f0e96310f53 1 parent dba521c
@serkanserttop authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  index.md
View
2  index.md
@@ -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++); }
};
```
Please sign in to comment.
Something went wrong with that request. Please try again.