user1184100
user1184100

Reputation: 6894

How to pass parameters to Backbone collection along with reset

I want to pass parameters as well as use {reset:true} when i do a fetch.

How can i accomplish both ?

Code

App.Collections.Items = Backbone.Collection.extend({

   model : App.Models.ItemInfo,
   url : "api/category/category123/city"

});

var itemCollection = new App.Collections.Items();
itemCollection.fetch({reset : true});

http://127.0.0.1/api/category/city?p=1&ps=4

How can I pass in p=1 and p=4 as the paremeters along with reset ?

Upvotes: 1

Views: 360

Answers (1)

Willem D'Haeseleer
Willem D'Haeseleer

Reputation: 20180

You can do it like this:

var itemCollection = new App.Collections.Items();
itemCollection.fetch({data: {p: 1, ps: 4 }});

Upvotes: 1

Related Questions