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

the $ in backbone.js View

What's the difference between jQuery $ and this.$ in Backbone.js View? in a View, I listened to a collection's reset event to empty an element by using below code //code in View this.$("#the_id").empty(); however it did not empty my element, then I…
Shuping
  • 5,388
  • 6
  • 43
  • 66
2
votes
1 answer

Backbone.js Collection.models not working

I have a Rails project with Backbone.js and HAML as client side templating language. in file app/assets/views/meeting.coffee: class window.MeetingIndex extends Backbone.View template: JST['meeting/index'] render: -> @collection.fetch() …
sites
  • 21,417
  • 17
  • 87
  • 146
1
vote
0 answers

show local json data from collection in backbone.js

I have a local json file. I need to put these data in a Backbone.Collection, then receive this collection in a Backbone.View and render the data in a template. So I tried many ways but... Model: define([ 'backbone', ], function(Backbone) { …
1
vote
1 answer

Populating data from two different url in a backbone collection

I have a Marionette.LayoutView which calls a backbone collection and fetches the data and renders based on response. Now the issue that I am facing is, this collection needs to get data from two different endpoints, both should be independent, and…
adarsh723
  • 135
  • 2
  • 3
  • 12
1
vote
1 answer

Why is there multiple copies of the collection nested inside the models?

I'm creating a collection in backbone js, after this fetch data from the backend, I print in the console inspector in chrome, but something caught my attention in the attributes. The collection has models, and inside of each model has an attribute…
Cristino
  • 311
  • 1
  • 7
1
vote
1 answer

How do you delete all models in an Alloy Collection

From within a controller function, how do you delete all the models in an Alloy Collection. The collection is using properties sync adapter. I think the backbone reset method is the way to go but I could not make it work.
1
vote
1 answer

How to search a Backbone collection with "any"?

Yesterday I found a code to search a Backbone collection using a any() function rather that something like. var myItem Collection.findWhere(...) if (myItem) { } But my file as been erased by TypeScript and "any" is such a vague keyword I can't find…
TTT
  • 1,848
  • 2
  • 30
  • 60
1
vote
1 answer

Update backbone view partially using timer in collection and get subset of a model

Am trying to update the some of the columns in table view when a timer triggered on collection am getting a subset of (only changed) properties. tried all kinds of codes from google but no luck. Want to update only age property out of name and…
1
vote
1 answer

Display a Backbone collection with HTML formatting

I have a Marionette CollectionView displaying some data from a collection. It's all working fine BUT some items in my collection has HTML tags. To make it easier, here is only two items: var topics = [ { content: 'This is a bold
1
vote
1 answer

Backbone listen to change event on collection of collection

Is it possible to listen to add, remove, reset, change event of one collection which is part of another collection? For example: Library having a collection of books. And each book can have multiple authors. Is there a way I can listen to event on…
1
vote
1 answer

Backbone - Updating models in collection with data polled from another API

I have a Backbone collection that I'm populating from an API endpoint. This return data such as: [ { "gameId": 1234, "gameName": "Fun Game 1" }, { "gameId": 1235, "gameName": "Fun Game 2" }, { …
Fraser
  • 14,036
  • 22
  • 73
  • 118
1
vote
1 answer

innerHTML 'each function' vs js file 'each function' when using underscore.js

I want to get array using underscore.js. Here is my case. view.js views.list = Backbone.View.extend({ render: function(templateName) { var template = _.template(templateName); this.$el.html(template({result :…
1
vote
1 answer

How to get elements from object where in Backbone?

I have object-model as: var wo = new WordModel({ "url": window.location.href, "time": toDay(), "w": w.trim() }); timelineCollection.add(wo); I try to get all element in timelineCollection where time is 04/02/2017. I tried this: var o =…
Darama
  • 3,130
  • 7
  • 25
  • 34
1
vote
1 answer

Is it possible to generate a unique id for new models in Backbone collection?

I have a Backbone collection from serer with attributes id and name. I get new name from input. var a = $('#newFoodtype').val(); And create new model and adding to collection; var b = new app.Foodtype({ "name" :a }); this.collection.add(b); The…
Przemek eS
  • 1,224
  • 1
  • 8
  • 21
1
vote
3 answers

When to destroy my model in case of multiple views depending on it

I have a case where I am creating multiple views for a single model. When I close a view, I am removing the model from the collection. But in case of multiple views, there are other views that depend on the model. So, how can I know when there are…