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
1
vote
2 answers

Populating model from a third-party API

I'm using Backbone for a personal project in which I created a model named MyModel. On initialization of this model, I want to populate its attributes from a JSON response from a third-party API: app.MyModel = Backbone.Model.extend({ url:…
JLA
  • 329
  • 1
  • 6
  • 12
1
vote
1 answer

Backbone Collection model duplicate itself

So, I have a table view (parent) and row view (child). I add every row with this code addOne: function (model, base) { var view = new App.Views.file_manager_item({model: model}); base.append(view.render()); }, renderList: function () { …
1
vote
1 answer

The collection nested inside firebase collection's model doesn't have add function

In my application, I am trying to use Firebase to store the real time data based on backbone framework. The problem goes like this: I have a sub level model and collection, which are both general backbone model and collection. var Todo =…
Chris Bao
  • 2,418
  • 8
  • 35
  • 62
1
vote
1 answer

Feed backbone collection with multiple different model classes

I have several models which have their own url/api they can fetch. I would like to keep them in a collection. does it sound like a good idea? how would you fetch them? (I'm thinking just to get the model I want to update from the collection then…
François Richard
  • 6,817
  • 10
  • 43
  • 78
1
vote
1 answer

Backbone.js multiple tables data manipulation

I have 3 separate tables in my page and they all get filled on View Initialize and fetch their data from my backend REST Api. After fetching data i bind the reset to method called paint and inside that loop through the collection and construct the…
1
vote
1 answer

Bubbling events in nested Backbone (Marionette) Models / Collections

We have a large Marionette App, that uses Backbone.trackit to monitor unsaved changes in our Models. We now have some nested models, in fact we have a Model, with a Collection of Models, that contain a Collection of Models. trackit doesn't support…
1
vote
2 answers

How to re fetch backbone collection after collection create?

Can someone tell me how to re fetch a Backbone collection after calling collection's create function when I create a new model? When I call fetch on my collection after creating new model, sometimes I'm getting that model and sometimes not. My…
lorenos
  • 115
  • 2
  • 12
1
vote
1 answer

Cannot read property 'type' of undefined with Backbone collection using different models

With Backbone (1.2.3), I'm trying to build a collection using multiple models using the collection's model property: var coll = Backbone.Collection.extend({ model: function(attrs, options) { switch(attrs.type) { case…
Menencia
  • 1,289
  • 1
  • 12
  • 23
1
vote
0 answers

Backbone.js - Creating models and collections for entities having two-way relationships

I am trying to build a simple student listing app using Backbone.js which will allow users to view: All the students of a university. All the courses available. All the students enrolled for a particular course. All the courses in which a…
1
vote
2 answers

Backbonejs view binding conceptual feedback

I ran into this article (http://coenraets.org/blog/2012/01/backbone-js-lessons-learned-and-improved-sample-app/) and was wondering if the idea of binding and rendering views in the router after instantiating them is best practice. I have been…
1
vote
2 answers

Sort backbone collection in specific order of enum sequence

I am having my backbone collection as below: var model1 = new Backbone.Model({mode: 'EX'}); var model2 = new Backbone.Model({mode: 'AB'}); var model3 = new Backbone.Model({mode: 'DF'}); var model4 = new Backbone.Model({mode: 'AB'}); var model5 = new…
Shaggy
  • 315
  • 2
  • 9
  • 23
1
vote
1 answer

Pass values between views in backbone

I have 2 views and need to pass values between them. var appModel1 = Backbone.Model.extend({ url: '/', defaults: { name: 'Default name' }, validate: function(attr){ } }); var…
1
vote
2 answers

Backbone Collection adding empty object when API returns no data

I have the following problem: My API returns null - no data available. (that's good!). My collection gets the data but creates one single empty object. My API result (from Firebug): {"data":{"objects":null}} My collection: var MyCollection =…
Ron
  • 22,128
  • 31
  • 108
  • 206
1
vote
1 answer

Sortby Collection BackboneJS With Lodash

I have collection like this: child{length:3, models:array[3], _byId:Object} I wanna sort models array, I use lodash like this: var array_of_objects = new ListCollection(); var data = _.sortByOrder(array_of_objects.models, ['id'], ['asc']); And I…
Wahyu Kodar
  • 654
  • 1
  • 6
  • 15
1
vote
1 answer

Query Collection using Where with a less than or greater than statement in it?

Does backbone collections using .where() or like function accept some form of less/greater-than statements such as <=, >=, <, > I cant find anything in the documentation that says anything either way
chris
  • 36,115
  • 52
  • 143
  • 252