Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
3
votes
1 answer
backbone fetch id changed
Has Model fetch behaviour, specifically setting the model id, changed between 1.1.0 and 1.1.2?
I've checked the changelog and can't find anything relevant.
The following no longer works:
var Wibble = Backbone.Model.extend({
urlRoot:…

tunny
- 483
- 1
- 4
- 5
3
votes
1 answer
backbone marionette related models
I'm trying to list some posts with their related users. Each post has a title some text and a userId like this:
[{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"text": "quia…

Marc Radziwill
- 175
- 2
- 12
3
votes
0 answers
How to use codeigniter rest api from Phil and Backbone.js to GET, POST , PUT, DELETE data?
I'm working with Phil rest library for codeigniter.
According to his documentation a rest api can have as many parameters as we want so, the url is structured as follows:
/method/{resource/value}
which translates into this
/users/id/1
and we can…

Lothre1
- 3,523
- 7
- 43
- 64
3
votes
1 answer
Backbone: Inherited Models not working in Collection with ID
I've run into this problem as I think I'm understanding Backbone incorrectly.
I have a super class called Runnable and a set of sub classes inherited from it:
var Runnable = Backbone.Model.extend({
template: $("#template"),
defaults:…

Dan0
- 459
- 3
- 16
3
votes
1 answer
backbone.js level 2 challenge 5 codeschool answer
One example in codeschool's backbone.js tutorial has the following solution:
Application.js
var appointment = new Appointment({id: 1});
appointment.on('change',function() {
alert('its changed');
});
I realize this is probably a simplified…

turbo2oh
- 2,849
- 6
- 34
- 46
3
votes
1 answer
What is the difference between attributes and options in Backbone.Model.Initialize
In the docs, they don't really explain the difference between what should go in options and what should go in attributes. Is it just model-specific data (like columns in your db) in attrbutes and other stuff in options?

bdwain
- 1,665
- 16
- 35
3
votes
1 answer
BackboneJs: Creating multiple models in a collection from a nested object
{
"code":"OK",
"message":"Success",
"errorFlag":"N",
"errors":null,
"data": {
"images": {
0: img0,
1: img1,
2: img2
}
}
}
This is a REST response and I wanted to put the…

Barry
- 1,587
- 2
- 13
- 19
3
votes
1 answer
Changing nested attribute with model.set in Backbone
I'm trying to do what I hope is a simple thing -- doing a model.set only on a sub attribute of the object.
Right now, I have a model that looks like this:
{
"attr1" : true,
"attr2" : this.model.get("username"),
…

streetlight
- 5,968
- 13
- 62
- 101
3
votes
3 answers
Model.set() with new and undefined values in Backbone.js
I would like to save calls to my server, so I am currently using Model.save() with the patch option and sending changedAttributes().
I would like to remove an attribute and add a new one. Model.set()/unset() will modify changedAttributes() each time…

clayzermk1
- 1,018
- 1
- 12
- 14
3
votes
1 answer
how to set backbone model idAttribute using nested property
My model is structured like this:
model = {
distance: 12.05,
widget: {
id: 1,
creationDate: '12/01/2012'
}
}
How do I set the idAttribute of the model to be the id on the widget property? Is there a syntax to do this?
user806273
3
votes
2 answers
What is the difference between set and save methods in backbone js?
What is the difference between Backbone js model set and save method ?
var book = new Backbone.Model({
title: "The Rough Riders",
author: "Theodore Roosevelt"
});
book.save({author: "Teddy"});
book.set("title", "A Scandal in…

Srinivas
- 1,516
- 3
- 17
- 27
3
votes
1 answer
Backbone and composite models in REST api - is it possible?
First I apologize as I am not sure the question title accurately describes what I am trying to do. I love/hate backbones REST api structure, but I am trying add on to it a bit and support a 'graph' of relationships between the models.
So the…

Matthew Ward
- 351
- 3
- 12
3
votes
2 answers
backbone.js model inheritance
I have a backbone model
var app = app || {};
app.Era = Backbone.Model.extend({
defaults: {
from: Number.NEGATIVE_INFINITY,
until: Number.POSITIVE_INFINITY,
stash: {
from: null,
until: null
…

lowerkey
- 8,105
- 17
- 68
- 102
3
votes
1 answer
Overriding Backbone Sync to use diiferent calls for fetch/save/destroy
The reason I'm late to the backbone party is because I'm worried it wont play nicely with my existing webservice. I have even got to the point where I'm using my own version of backbones controllers and models, but its fruitless to just write my…

Jon Wells
- 4,191
- 9
- 40
- 69
2
votes
1 answer
Why resetting a form does not clear the bound model attributes
I have bound the text inputs in a form to a Backbone Model using backbone-stickit bindings:
bindings: {
'#txtRemarks': 'remarks',
'#txtFromAccountNumber': 'account_no',
'#fileChooser':'fileChooser'
}
When I reset the form, the values in…

M Hari
- 113
- 2
- 10