Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
fix Backbone.sync mock logging example
Browse files Browse the repository at this point in the history
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
serkanserttop committed Aug 22, 2012
1 parent dba521c commit 853cf29
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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++); }
};
```

Expand Down

0 comments on commit 853cf29

Please sign in to comment.