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

Setting Default Options for Backbone Collections

I have a Backbone Collection like so: var ThreadCollection = Backbone.Collection.extend({ url: '/api/rest/thread/getList' }); var myCollection = new ThreadCollection(); And then I'm fetching it from the server using the data object to append the…
Evan Hobbs
  • 3,552
  • 5
  • 30
  • 42
3
votes
2 answers

Why does the backbone.js where function return an array of models?

When I use the Backbone.Collection.where function to filter the collection I get an array of models as return value but not an other filtered collection object. So I can't use other collection functions with that. What is the purpose of such…
fey
  • 1,289
  • 1
  • 10
  • 20
3
votes
1 answer

Backbone paginator not paginating my collection

define([ 'underscore', 'backbone', 'models/shared_object', 'backbone_paginate' ], function(_, Backbone, Shared_Object){ "use strict"; var myCollection= Backbone.Collection.extend({ initialize: function(option) { …
3
votes
3 answers

2 backbone.js collections with same models but different sort orders

I have to display the same collection of backbone models in 2 different places on the same page (once in the navigation, once in the main area), and I need to keep the models in the collections in sync but allow each collection to be sorted…
Peter Lyons
  • 142,938
  • 30
  • 279
  • 274
3
votes
2 answers

Backbone.js - getting id from collection create

I am adding a model to a collection using the create method and the api is responding just fine. The model seems to have been properly returned and see the console.dir( resp ); which is what I was looking for. However, when I try to access…
Joe
  • 1,841
  • 4
  • 27
  • 43
3
votes
1 answer

0.5.3 to 0.9.2 adding to collection inefficiency

I upgraded from 0.5.3 to 0.9.2 of backbone.js and I noticed a significant decrease in speed on my application. The application handles many large collections and adds a large number of models at certain points. There is anywhere between 0 to 600…
georgephillips
  • 3,540
  • 4
  • 23
  • 30
2
votes
2 answers

Update a model but persist the whole Backbone collection

My API response: { firstName: '', lastName: '', notifications: [ { category: '1', subcategory: '', source: '', optInDate: '', optOutDate: '', active: '' }, { category: '2', …
2
votes
1 answer

How do I execute a custom backbone sort on different attributes?

I'm trying to do the following. I would like to sort some baseball players with this in mind. Managers should be at the top (sorted by active then name), then I would like to sort the player or any other type - could be several other types by…
KingKongFrog
  • 13,946
  • 21
  • 75
  • 124
2
votes
1 answer

how to make a search form using backbone.js

I am working with Backbone.js for the very first time, and trying to get my head around how it works. I want to make a search form but i am stuck at starting point. Here is my input search box and i want…
2
votes
1 answer

.fetch() collection backbone.js doesn't work

I want to call API URL to get data, and pass it to a view, but encounter an error when using fetch property: Uncaught TypeError: Cannot read property 'localStorage' of undefined at G.d.Backbone.sync (backbone.localStorage-min.js:8) at…
2
votes
3 answers

How to pass variable instead of url in Backbone.Collection

I try to pass my data into Backbone.Collection without using url. I just have a response with array of objects and what I need is to pass a variable into url. But url is a path in a working directory to a json file or a url to the server. So how can…
2
votes
1 answer

backbone filter collection to return models by name?

I am trying to filter a collection a collection by a models attribute (name), byName: function(searchParam) { var filtered = this.filter(function(model){ console.log(model.get('name').toLowerCase()); …
Udders
  • 6,914
  • 24
  • 102
  • 194
2
votes
1 answer

Backbone: Show validation errors for each model in a collection on VIEW

I'm working on a Backbone application where I allow the user to Add multiple items. Here's my Model: //Model var Item = Backbone.Model.extend({ defaults: { part1: 'hello', part2: 'world' }, validate: function…
Abhishek
  • 1,974
  • 5
  • 31
  • 67
2
votes
2 answers

Why the 'fetch function' automatically call the 'parse function' on backbone.js collection?

I am trying to parse my json file into Backbone collection and model as like below. This is .json file [ { "type": "rect", "x": 10, "y": 10, "w": 100, "h": 100, "color": "red" }, { "type": "arc", "x": 210, "y":…
2
votes
2 answers

Backbone fetching data from model vs collection

I created a simple backbone project, where it fetches all books details and show it in UI. I am fetching all the books details from the model. not at all using collection something like this var BookModel= Backbone.Model.extend({ initialize:…