Skip to content
This repository was archived by the owner on May 17, 2018. It is now read-only.

initialize() method only supports the "models" parameter as an array#76

Merged
wyuenho merged 2 commits intobackbone-paginator:masterfrom
gbedardsice:master
May 1, 2013
Merged

initialize() method only supports the "models" parameter as an array#76
wyuenho merged 2 commits intobackbone-paginator:masterfrom
gbedardsice:master

Conversation

@gbedardsice
Copy link
Copy Markdown
Contributor

In the initialize method, the "models" parameter is considered an array. The thing is, in a plain backbone collection, I can do something like:

var collection = new Backbone.Collection({hello: 'world'})

and it will instantiate the collection with a single model in it.

But if I do this with a pageable collection, I get errors because an object is not expected.

@wyuenho
Copy link
Copy Markdown
Member

wyuenho commented May 1, 2013

This isn't actually advertised or documented. In fact there isn't a test case that guarantees this behavior in Backbone. It's just a side effect that Backbone.Collection's constructor delegates to reset which delegates to add. I don't have anything against supporting this tho, it should be fairly easy. PR welcome.

Comment thread lib/backbone-pageable.js Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change _.isArray to _isArray to help the minifier with name mangling.

wyuenho added a commit that referenced this pull request May 1, 2013
Support non-array elements in the constructor
@wyuenho wyuenho merged commit 4f4ad59 into backbone-paginator:master May 1, 2013
@wyuenho
Copy link
Copy Markdown
Member

wyuenho commented May 1, 2013

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants