brianleroux / lawnchair

A lightweight clientside JSON document store,
http://brianleroux.github.com/lawnchair
MIT License
2.13k stars 246 forks source link

Calling .save on a Lawnchair instance causes all instances to save #115

Open jaypeeZero opened 12 years ago

jaypeeZero commented 12 years ago

My app is organized in a way that major sections of the site have their own Lawnchair instance. They all have their own name set up and using .get or .all or .keys works as I would assume.
lawnchair.get('projects') returns only the Projects and not the Users or Tasks.

However,
lawnchair.save('projects') actually causes ALL lawnchair instances to save.
I have 'this.before('save')' set on all my lawnchair instances and when saving one of them, they all fire that event. Even going into Console in Chrome and creating a brand new blank lawnchair instance and calling ".save" causes all my previous instances to save.

I'm using Lawnchair version 0.6.1

brianleroux commented 12 years ago

Would you be able to create a quick failing test for me James? I'm not able to repoduce!

jaypeeZero commented 12 years ago

I can't get the jsFiddle to work correctly (won't import Underscore.js and Backbone.js for some reason) but this is effectively the dumbed down code.
Note that I used to have it as "that.lawnchair = Lawnchair..." but switched to "that.lawnchair = new Lawnchair...". Both methods produce this bug.
EDIT
I forgot that copy-paste from jsFiddle causes weird bugs so I changed the link to a gist instead. I tested this gist locally on my computer and it produces the same bug of causing the before and after events to fire on all Lawnchair instances

sangeethkumar commented 12 years ago

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">