pathable / supermodel

Supermodel - Minimal Model Tracking for Backbonejs
http://pathable.github.io/supermodel
MIT License
229 stars 36 forks source link

Model.create not passing options #53

Closed jessehouchins closed 10 years ago

jessehouchins commented 10 years ago

Model.create does not pass options when an existing model is found: https://github.com/pathable/supermodel/blob/master/supermodel.js#L479

Should be:

if (id && model) return model.set(model.parse(attrs, options), options);
jessehouchins commented 10 years ago

Note: if anyone implements this, DO NOT let the silent option through to the set... it prevents associations from being updated.

braddunbar commented 10 years ago

Great point. {silent: true} is generally troublesome in my experience.

braddunbar commented 10 years ago

Thanks for reporting! Fixed in 0c6d42c.

jessehouchins commented 10 years ago

you forgot to omit the silent option... it gets set automatically during collection initialization and can blow shit up if the models being initialized with the collection already exist in the all collection...

braddunbar commented 10 years ago

Ah, I thought you were referring to users of silent, not omitting it here... :neutral_face:

You're right, but I don't think we can prevent it regardless. If we omit silent then we subvert the users intent to silence events. If we let it pass we prevent associations from functioning correctly.

Also, why would you pass silent: true to Model.create (out of curiosity)?

jessehouchins commented 10 years ago

The backbone collection constructor does it automatically: https://github.com/jashkenas/backbone/blob/master/backbone.js#L632

Also, not allowing silent through just keeps current functionality in that respect since it wasn't getting through before anyway.

braddunbar commented 10 years ago

Oh man, I didn't even think about the silent option from reset as I think it's intended for Collection#add, not Model#set. :unamused:

Not much way around it I suppose. Updated in bafa07e. Thanks again!