Questions tagged [backbone.js-collections]

For Backbone questions specific to Backbone's collections.

Backbone collections are order sets of models. Collections forward events on their models to the collection's listeners for convenience.

523 questions
2
votes
2 answers

Backbone.js Collection Size - Don't display if limit reached

I have the following code in my Backbone Collection loadMore: function() { this.offset += 1; this.fetch({ data: { limit: 50, skip: this.offset }, remove: false, …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
2
votes
0 answers

Backbone collect reset not triggering event

I have a method in my collection that performs a filter. filterByCategory: function() { this.collection.reset(this.collection, {silent: true}); var filterCategory = this.filterCategory; var filtered = _.filter(this.collection.models,…
Bender
  • 581
  • 1
  • 6
  • 20
2
votes
1 answer

Backbone: Batch save models in single request?

I have a single page application using backbone to manage a collection of models. Sometimes this collection gets quite large and if the user performs operations that change a lot of them this can result in .save getting called lots of times. In…
Chris
  • 6,076
  • 11
  • 48
  • 62
2
votes
1 answer

Creating a Backbone.js Model with complex JSON

I have JSON response as follows { "results": [ { "name": "FOO", "containerName": "Foo", "accounts": [ { "id": "10445570_7601", …
2
votes
1 answer

Does BackboneFire support non-AutoSync collection with AutoSync model

Basically I want this set up: var Game = Backbone.Model.extend({ defaults: { }, autoSync: true }); var Games = Backbone.Firebase.Collection.extend({ url: 'https://.firebaseio.com/games', autoSync: false, model:…
2
votes
1 answer

Change details on Backbone.JS collection change event

Is there a way to gather more information about the changes from within the Backbone.JS collection change event. What I would like to figure out is whether or not it possible to to know what the collection change was; was a model updated, was one…
titel
  • 3,454
  • 9
  • 45
  • 54
2
votes
3 answers

pass parameters to backbone fetch url to deal with a non-standard api

I am trying to manipulate backbone's fetch method to to deal with a bit of a non-standard api. The way the api works is as follows: api/products/[page]?param1=val¶m2=val ex: api/products/2?budget=low&categories=all would be equivalent to…
mheavers
  • 29,530
  • 58
  • 194
  • 315
2
votes
1 answer

Model not being pushed into collection of backbonejs

jsfiddle I'm trying to create a message client using this tutorial at this point, the view is supposed to be updated when a new message is typed into the field and the add button is clicked. For some reason the "addMessage" Event is failing to add a…
2
votes
1 answer

Fetch models as needed in Backbone Collection?

I would like something like the following behavior: Call get() on a collection. Fetch the model only if it has not yet been fetched. Return the model or fire an event signifying that it is ready. Is there a standard way to do this in backbone?
elplatt
  • 3,227
  • 3
  • 18
  • 20
2
votes
2 answers

Why does Backbone's collection create() method not populate the id?

In my view's method below, my model gets synced with the server if I understand the create() method properly. However, the console.log of this.model.id still returns undefined and this.model.isNew() returns true. The POST shows an id in the return…
2
votes
1 answer

Backbone binding to add event on collection

I have problem with backbone collections. I trying to listen all events on collection: this.collection.on('all', function(ev) { console.log(ev); }); And collection trigger event only when I create record like this: …
ssbb
  • 1,965
  • 2
  • 14
  • 26
2
votes
2 answers

Is it possible to know which one triggered Collection's add event: fetch or create call?

I need to tell if model inside add event was retrieved with collection.fetch or created by collection.create. Is it possible? collection.on('add', onModelAdded) collection.fetch() collection.create({}) function onModelAdded(model, collection,…
Andrey Kuzmin
  • 4,479
  • 2
  • 23
  • 28
2
votes
1 answer

Backbone Collection add strange behavior in Firefox

Faced with such a strange problem with Backbone collection. I tried to add new elements in these way: sortCollection.add([ {id: "recommended", title: 'Recommend movies'}, {id: "popular", title: 'Popular movies'}, {id:…
LadyBo
  • 145
  • 7
2
votes
2 answers

Backbone.Marionette throwing error trying to use CollectionView

I am getting stuck on a pretty annoying issue and decided to look for help as the error is hard to figure out. I have a Marionette Layout view in a single page application representing the panel that switches out. I have it working fine until I try…
2
votes
1 answer

Backbone Collection Set method remove existing elements and then add all elements

I have a backbone collection.I want to add or remove some models dynamically in the collection. But if i am using collection.set() method then it is going to remove first all elements and then it will add all elements again. What i want to do is…
user2058320
  • 97
  • 4
  • 12