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
10
votes
1 answer

What is the AngularJS equivalent to Backbone's Collections?

Is there an equivalent to Backbone's Collection or Ext JS's Store in Angular JS? I'm learning about $resource, but not quite getting this aspect. Controller // This is the "collection" I'm interested in. $scope.foos = []; // Foo is a…
10
votes
1 answer

Backbone.js fetch method with data option is passing URL params with square brackets

I have the following code to fetch the data for my collection but with specifying what colors should come from the server: fruits = new FruitsCollection(); fruits.fetch({ data: {color: ['red', 'green']} }); This is what I…
Cristian Rojas
  • 2,746
  • 7
  • 33
  • 42
10
votes
4 answers

detect when a backbone collection has been fetched (Backbone 1.0.0)

There's a new behaviour in the latest version of Backbone (1.0.0 in which the reset event is no longer triggered by default after fetching a Collection. http://backbonejs.org/#changelog Renamed Collection's "update" to set, for parallelism with the…
opensas
  • 60,462
  • 79
  • 252
  • 386
10
votes
2 answers

Retrieving index position of item added to Backbone.js Collection

If I add an item to a Collection how can I find the position at which it was added? The Underscore.js documentation for add suggests the only way to achieve this is by binding to the add event. Is there any other way? If not, then how can I reteive…
Jack
  • 10,313
  • 15
  • 75
  • 118
9
votes
1 answer

Backbone: How to update a collection view when collection changes?

I'm relatively new to Backbone.js. I'm initializing a collection view and passing in a collection at creation time. suggestionsView = new TreeCategoriesAutoSuggest.Views.Suggestions({ collection: new…
Alex B
  • 1,009
  • 3
  • 18
  • 26
9
votes
3 answers

BackboneJS model.url using collection.url

From my understanding the default behavior of Backbone JS Models are to return the Collection's URL, unless the model has a urlRoot specified. I can't seem to get the behavior to work. From the documentation: model.url() ... Generates URLs of the…
caleb
  • 93
  • 1
  • 1
  • 4
9
votes
3 answers

Backbone Collection of polymorphic Models

I have a collection of Animals. App.Collections.Animals extends Backbone.Collection model: App.Animal url: '/animals/' #returns json And these animal classes: App.Models.Animal extends Backbone.Model App.Models.Monkey extends…
Andreyy
  • 511
  • 2
  • 11
9
votes
2 answers

Backbone collection where clause with OR condition

I have searched for this for quite some time but could not get a way to have a where clause with or condition. For example if I have a collection Cars and I try to do the following: Cars.where({ model: 1998, color: 'Black', …
aditya_gaur
  • 3,209
  • 6
  • 32
  • 43
8
votes
3 answers

Is it possible to initialise a backbone Collection with object IDs rather than objects?

I have a Backbone.js Collection and I have an array of model IDs that I want to populate it. I know that I could fetch these objects one by one, build an array of objects and pass them into the Collection's constructor as an array. What I'd like to…
Joe
  • 46,419
  • 33
  • 155
  • 245
8
votes
3 answers

How do I bootstrap a collection in Backbone.js using Javascript only

Context: I am building an application that needs several large collections of reference data to operation. I am limited to HTML and Javascript only (including JSON). Question: How do I bootstrap a collection in Backbone.js where the collection…
7
votes
1 answer

What is the best approach to replace Parse.Collections in JavaScript

Parse.com has removed the Backbone style Parse.Collection from the JS SKD (from here https://parse.com/docs/downloads): SDK no longer contains Backbone-specific behavior. Moving forward, the core SDK will not be tied to any single framework, but we…
otmezger
  • 10,410
  • 21
  • 64
  • 90
7
votes
1 answer

Best Practice for moving backbone model within a collection

Related Questions - BackboneJS best way to rearrange models in a collection while maintaining 0-indexed ordinal property for each model How can I move a model within a collection? I have a Backbone collection, visually represented in a list. This…
iabw
  • 1,108
  • 1
  • 9
  • 24
7
votes
3 answers

Mapping JSON to backbone.js collections

Alright, it looks like I need a hint to point me in the right direction. This question is two part - working with mult-dimensional JSON and Collections of Collections from JSON. Background I have some JSON that is going to be retrieved from a server…
Sir.Nathan Stassen
  • 1,843
  • 4
  • 21
  • 25
6
votes
2 answers

Backbone.js - fetch method does not fire reset event

I'm beginning with Backbone.js and trying to build my first sample app - shopping list. My problem is when I fetch collection of items, reset event isn't probably fired, so my render method isn't called. Model: Item = Backbone.Model.extend({ …
chr1s
  • 135
  • 1
  • 4
  • 8
5
votes
1 answer

Why doesn't Backbone Collection fetch return a promise

The following example code works well: Auth_controller.prototype.isLogged = function(){ //Check if the user is authenticated var getAuthStatus = this.auth_model.fetch(); return getAuthStatus; }; Auth_controller.prototype.redirect…
html_programmer
  • 18,126
  • 18
  • 85
  • 158
1
2
3
34 35