Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
6
votes
2 answers
backbone.js View determine which attribute of model is change
How can I know which attribute of the view model is changed in the render function? (In the render function, "e" is the model, but I need only the attribute which is changed.) I need to know this to know which template to use. Or is there another…

Florim Maxhuni
- 1,421
- 1
- 17
- 35
6
votes
3 answers
how to access a models data from a view in backbone.js
I have a model named person:
var person = Backbone.Model.extend({
initialize: function(){
console.log('cool');
},
defaults:{
names:['a','k','d','s','h','t']
}
})
Now I have a view:
var person_view =…

Wern Ancheta
- 22,397
- 38
- 100
- 139
5
votes
1 answer
Backbone model.create not calling any callback
I have the following code to create a new model to a collection. The underlying datastore is a remote API:
var postCreationStatus = this.model.create(newPostModel, {
wait : true // waits for server to respond with 200 before…

Ayush
- 41,754
- 51
- 164
- 239
4
votes
1 answer
Nested Models and Collection in backbonejs
I am looking for a solution to load the nested json in the parent model to be eventually rendered on screen.
I have a nested json in this format:
{
"name":"Hotel-A",
"description":"5 star rating",
"geographicAddress":{
…

toddler
- 45
- 5
4
votes
1 answer
backbone.js adding model to collection adds to all models in collection
Playing around with backbone.js, so far I've created models and collections for a deck of cards and two players. The problem is when I try move a card from the deck and add it to the player's hand the card gets added to all players hands.
Here's my…

captain_stupid
- 41
- 5
4
votes
1 answer
listen to a collection add/change as a model attribute of a view
I have a Measure View, and it has an associated Measure Model, which has two collections, RepresentationsCollection and BeatsCollection. The Measure View has nested child Representation views, each with their own representation model, and all…

chris Frisina
- 19,086
- 22
- 87
- 167
4
votes
3 answers
Return promise from a Backbone Model
I have a model, which is fetched from the server. I would like to return a promise on creation, so that views that are using this model know, when to render.
I could bind the promise to the window (or app), but a neater way would be to just return…

johnny
- 8,696
- 6
- 25
- 36
4
votes
1 answer
Is it an anti-pattern to instantiate models in views in Backbone.js?
When developing Backbone applications, I often find myself instantiating models in views when dealing with nested data. Here's some example data:
{
name: Alfred,
age 27,
skills: [
{
name: 'Web development',
level: 'Mediocre'
…
user1781186
4
votes
2 answers
How to handle multiple backbone model changes in one handler
I have a View and a Model associated with it in backbone. View observe for model changes and change its displaying area accordingly. for example:
var Part = Bacbone.Model.extends({
defaults:{
partId = null,
manufacturer: null,
…

Kunal Gupta
- 41
- 4
4
votes
7 answers
Backbone Model gives this.set not a function in Model.initialize
I've a model listen on the vent for a event update:TotalCost, which is triggered from (unrelated) Collection C when any model M belonging to collection C changes.
This event is coded in the initialize method as below. On receiving the event I get…

Nilesh Kale
- 233
- 1
- 4
- 12
4
votes
2 answers
Fetch data from different urls using the same collection in backbone js
I have a collection which has to call 4 external apis Eg: http://www.abc.com, http://www.fgt.com, http://www.jkl.com and http://www.rty.com.
I have a Collection named Todos.js. Is there a way I can fetch the 4 apis together in a single collection…

Sudo
- 559
- 1
- 8
- 15
3
votes
1 answer
Adding models to collection throws error "Uncaught TypeError: Cannot read property 'idAttribute' of undefined"
I'm having an error trying to add multiple models from the server to a collection. It throws the error:
Uncaught TypeError: Cannot read property 'idAttribute' of undefined
Here is a test example which gives same error: