Reputation: 28111
In Backbone.js
I can appoint where the model fetches it's data:
var Book = Backbone.Model.extend({urlRoot : '/books'});
var mybook = new Book({id: "1"});
mybook.fetch(); //it will access '/books/1'
But if I want to append a query string after the URL? e.g. the book data is at /books/1&details=true
. Can I specify this in model?
Upvotes: 21
Views: 11177
Reputation: 5468
You can also use the option for the method fetch
mybook.fetch({data:{details: true}});
Upvotes: 45
Reputation: 47833
You will have to use a custom url function for the model.
Book.url = function() {
return this.urlRoot + '/' + this.id + '?details=true';
};
Upvotes: 22