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

Commit

Permalink
Fix #30, error using fetch when collection's url is a method
Browse files Browse the repository at this point in the history
  • Loading branch information
Amitava committed Jan 18, 2013
1 parent 3a06f51 commit fe5c3af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/backbone-pageable.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@

// dedup query params
var url = options.url || this.url || '';
url = typeof url == 'function' ? url() : url
var qsi = url.indexOf('?');
if (qsi != -1) {
_extend(data, queryStringToParams(url.slice(qsi + 1)));
Expand Down
14 changes: 14 additions & 0 deletions test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,20 @@ $(document).ready(function() {
equal(this.syncArgs.options.parse, false);
});

test("ensure fetch works if a collection's url is a method", 4, function() {
var collection = new Backbone.PageableCollection;
collection.url = function() {
return '/test';
}
collection.fetch();
equal(this.syncArgs.method, 'read');
equal(this.syncArgs.model, collection);
equal(this.syncArgs.options.parse, true);

collection.fetch({parse: false});
equal(this.syncArgs.options.parse, false);
});

test("ensure fetch only parses once", 1, function() {
var collection = new Backbone.PageableCollection;
var counter = 0;
Expand Down

0 comments on commit fe5c3af

Please sign in to comment.