Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
0
votes
2 answers
Different model types in one collection Backbone
Backbone 1.1.2
Underscore 1.7.0
jQuery 1.11.1
I have a single collection that holds messages.
My messages can be be of different types (and the endpoints in the api are different for each type, but I have an endpoint that allows me to do one…

Beyerz
- 787
- 2
- 9
- 20
0
votes
1 answer
What is this.module and when do we use it in Backbone.js application?
Recently, I have started working on a project and in the code base I am finding lots of this.module statements (not this.model). As a beginner in backbone, I have no idea when should I use this and why? Any explanation would be really helpful.

Sharif Mamun
- 3,508
- 5
- 32
- 51
0
votes
1 answer
Backbone change event not firing when certain attributes are changed
In my backbone application, I have a model that looks a little like this,
{
"id" : 145,
"name" : "Group Number 1",
"information" : "Some kind of blurb about group number 1",
"members" : {[
"id" : 1,
"first_name" :…

Udders
- 6,914
- 24
- 102
- 194
0
votes
2 answers
Should Backbone Model represent a view or a server-side resource?
Assume a situation where I've a Rails AR models as below
class User
has_one :profile
end
class Profile
belongs_to user
has_one :address
end
class Address
belongs_to :profile
end
And have a User Profile view to be constructed at the…

karthiks
- 7,049
- 7
- 47
- 62
0
votes
1 answer
Backbone model when created already has attributes
In my my application I do something like this to create a new model,
this.model = new App.Models.Organisation;
The code for the model looks like this,
'use strict'
App.Models.Organisation = Backbone.Model.extend({
urlRoot: "http://" +…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
Backbone running a method based on a collection listener
In my application have the following code,
initialize: function() {
Pops.Collections.TeamCollection = this.collection;
this.collection.fetch();
this.collection.on('sync', this.render, this);
},
render: function() {
this.addAll();
…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
Refer model from collection
I am using Backbone to structure my web application, this is my situation:
Section = Backbone.Model.extend({
initialize: function(){
this.set("elements", new ElementCollection());
}
})
ElementCollection =…

steo
- 4,586
- 2
- 33
- 64
0
votes
1 answer
Model attributes not getting set correctly after a fetch
In my model I have some nested collections, the API returns some data, and this gets parsed into a model fine, however because my API returned arrays in objects some of my attributes tend to look like this when logged...
member: Array[2]
In my model…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
backbone collection get list of single attributes
I am wanting to get a list from my collection, the list will be used to add options to a select list. I am wanting to use this to filter the collection,
So for example I am want filter my collection by the group attributes, so first I need to get…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
BackboneJs application not rendering anything
Click here for the js fiddle example
This template should render new messages in a collection, im trying to follow this tuorial
with my own version that renders messages instead