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?
You can also use the option for the method fetch
mybook.fetch({data:{details: true}});
You will have to use a custom url function for the model.
Book.url = function() { return this.urlRoot + '/' + this.id + '?details=true'; };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With