jeromegn/Backbone.localStorage — Issue #20: Collection.each doesn't provide each?
Author: lorensr
Created: 2011-12-23 05:16:24+00:00
State: open

The first time I call each, to save the sessions, it gets both. The second time, when destroying, it only gets the first. Any idea why?

```coffeescript

class Session extends Backbone.Model

class SessionList extends Backbone.Collection
model: Session
localStorage: new Store 'sessions'

window.sessions = new SessionList

localStorage.removeItem('sessions')
console.log localStorage.sessions

sessions.add [
{x: '1'}
{x: '2'}
]
console.log localStorage.sessions

sessions.each (m) ->
console.log 'saving' + m.get('x') + ' ' + m.get('id')
m.save()
console.log localStorage.sessions

sessions.each (m) ->
console.log 'kill' + m.get('x') + ' ' + m.get('id')
m.destroy()
console.log localStorage.sessions
```
Console log:

```
undefined
undefined
saving1 undefined
saving2 undefined
afe778bf-74e1-8013-6cca-ecb8bed794f7,78716671-68cc-de7d-914e-2d64531efc6e
kill1 afe778bf-74e1-8013-6cca-ecb8bed794f7
78716671-68cc-de7d-914e-2d64531efc6e
```