Skip to content
This repository was archived by the owner on May 17, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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] : [];
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.


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