Skip to content
This repository has been 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
merged 2 commits into from
May 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/backbone-pageable.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@
state.firstPage :
state.currentPage;

if (!_isArray(models)) models = models ? [models] : [];

if (mode != "server" && state.totalRecords == null && !_isEmpty(models)) {
state.totalRecords = models.length;
}
Expand Down
8 changes: 8 additions & 0 deletions test/client-pageable.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ $(document).ready(function () {

var mods = models.slice();

col = new Backbone.PageableCollection(mods[0], {
mode: "client"
});

strictEqual(col.state.totalRecords, 1);
strictEqual(col.fullCollection.size(), 1);
strictEqual(col.fullCollection.at(0).get("name"), "a");

col = new Backbone.PageableCollection(mods, {
comparator: comparator,
state: {
Expand Down