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

Backbone collection length always set to one with nested views

When the view is loaded, the collection length always return 1 while there is currently 3 members shows up in the parse function. I wondered if the problem was the nested item view, but it seems to behave the same without ! I don't understand why…
2
votes
2 answers

Update a Backbone Collection property on add/remove/reset

I have a Backbone Collection, and I want it to respond in some way to its own updates (i.e. additions, removals, resets). I've run into this in various scenarios, but for the sake of discussion, let's say I'm computing a hash based on model ids, to…
nrabinowitz
  • 55,314
  • 10
  • 149
  • 165
2
votes
1 answer

Backbone JS add extended model to a collection of its inherited model type

I've just started digging into backboneJS, and have built started building a small text app in codepen (http://codepen.io/azaslavsky/pen/fJghE). Everything is going well, except I have one problem: once the user hits the submit button, I'd like for…
AlexZ
  • 11,515
  • 3
  • 28
  • 42
2
votes
1 answer

Multiple collections tied to one base collection with filters and eventing

I have a complex model served from my back end, which has a bunch of regular attributes, some nested models, and a couple of collections. My page has two tables, one for invalid items, and one for valid items. The items in question are from one of…
damienc88
  • 1,957
  • 19
  • 34
2
votes
1 answer

backbone model loop outputs final object instead of iterator

So im trying to fill in the array "cat" with five rows that will keep a running count of the number of times each category occurs in a step. The problem is the loop executes but it doesn't output the results one by one so I can see the progression…
2
votes
0 answers

Backbone.js Fuse.js render filtered collection

Im trying to add a fuzzy search feature to filter objects in a collection. The console is showing that the Fuse is working correctly and returning the correct objects. Now the question is how do I pass the filtered collection to my view to be…
2
votes
1 answer

Backbone view based on model from collection, how to update view?

I am looking for a bit of direction I am still fairly new to Backbone and am currently creating a test application to learn more. My problem is this, I am populating a backbone view with a underscore template. I load a collection of models, then I…
2
votes
1 answer

Knockback.js backbone collection only adds first element to UI

I'm trying to set something new up with Knockback.js, and right now I'm running into an issue with the knockout/knockback integration. The problem is, I've successfully written an event handler which adds a new model to the Objectives collection,…
2
votes
2 answers

low coupling: add a model to a collection of a different view

i'm building a Backbone/Marionette application to list different sets of cards. the layout has an ItemView on the left side including an input field to add a new set and a CompositeView on the right side to list the card…
2
votes
1 answer

Can't loop over backbone collection

It seems that I can't loop through a backbone collection. I've seen this topic in several threads, but none of those solutions help. render:function () { this.$el.html(this.template(this.model.attributes)); var that = this; …
2
votes
1 answer

Backbone: Assign different collection to view

After having initialised a view in Backbone (actually Marionette), is it possible to change its collection? I use a nested model of a list of (main) items with additional sub items. The view displays all main items and depending on the current…
orange
  • 7,755
  • 14
  • 75
  • 139
2
votes
0 answers

How to insert pagination in my backbone.js exercise

I'm trying to learn backbone.js and in this exercise I have a view that show elements from a collection. This collection fetch data from a backend that export json file like this: { "users": [ { "name": "Jeffrey Way", …
Zerri
  • 31
  • 1
  • 3
2
votes
2 answers

How do I use & access a Backbone.js Collection as property/attribute in a Model?

I'm new to Backbone (still stuck in Ruby on Rails mode) and am a bit confused about how to add a Collection to a Model as a property/attribute (is "attribute" the correct term?). For example, I have a Model named current_plan, and a variable named…
2
votes
2 answers

Setting a model type to a collection with external url in backbone

I am creating a collection that has an external url something like this: var todoCollection = Backbone.Collection.extend({ model: Todo url: function() { return "http:externalurl.com"; }, parse: function(dat) { …
Sudo
  • 559
  • 1
  • 8
  • 15
2
votes
1 answer

backbone.js error when using fetch but not $.ajax()

I am having some trouble fetching a collection. I'm using the console's network inspector to see if I can figure out what's wrong and the only thing I see is the format of the Request Payload. When making a .fetch() the Request Payload is being sent…
Charles
  • 309
  • 1
  • 16