New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection.add return value no longer the same as Backbone.Collection's #419
Comments
Yeah, ok, I'm seeing the issue for all 4 functions. Here's some quick and dirty code showing the problems:
|
Fiddle: http://jsfiddle.net/RrAsW/ |
Worked around bug in backbone-relational: PaulUithol/Backbone-relational#419
This was the correct behavior for Backbone 1.0. Backbone 1.1 adds different behavior when 'single' models are added to a collection. |
Any chance of seeing a new release with this fix? Cheers. |
Yep, I'm looking a couple more issues I'd like to fix before creating a new release. Won't be too long (well, I hope ;). |
* upstream/master: (35 commits) Upgrade qunit Fix subModels not being populated properly on Underscore 1.6.0, due to `_.each` api change. Fire change events right away if we're not in a nested scenario. Fixes PaulUithol#427 Document `store.unregister` `store.unregister` now also accepts collections or a model type Change `findOrCreate` to pass `parsedAttributes` to `build`, and adjust tests to reflect change. Remove unnecessary locking Update change log Add test for models not being added to store until they get an id Change where we listen to `relational:unregister`. Only add models with an id to the store. Closes PaulUithol#411 Fix a bug in the (crude) performance test Add a small test for `clear` Fix collection return values when setting/removing `[]` and `null`. Ref PaulUithol#419 Clarify the behavior of `findOrCreate` when it just a receives a scalar value. Ref PaulUithol#399 Proper return values on collection methods for Backbone 1.1. Closes PaulUithol#419 Submodels: accommodate multiple 'type' keys for the same submodel. Closes PaulUithol#429 Hmm, fix spaces/tabs mix in the example Update a few version numbers in the docs to 0.8.7 Backbone-relational 0.8.7 ...
According to the Backbone docs,
Collection.add()
returns the added model (or array of models when adding multiple), and the changelog says this changed for all ofset
,add
,remove
, andreset
in version 1.1 (previous behaviour was to return the collection).Issue #412 and associated fix 285161e shows some work was done on this to bring backbone-relational into line (specifically for
set
) in master.Unfortunately either
add
didn't get the same love, or the fix didn't work completely -- I'm seeingadd
return an array in both cases, instead of just the model when adding a single item (using backbone-relational master).I haven't checked whether
set
,remove
, andreset
are likewise affected.The text was updated successfully, but these errors were encountered: