Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
0
votes
1 answer
Backbone.js, using urlRoot result in view
I am a Backbone.js newbie and I'm just playing around with it. I would like to know how the model is related with the View when using urlRoot. I'm using a local restful service. When calling 'api/feed/57' I get the following JSON…

Erhnam
- 901
- 2
- 13
- 23
0
votes
2 answers
Detect when Backbone has finished a model fetch
I can't seem to figure out which event to listen to when fetching data for a model. Usually when I'm doing it for a collection, I listen to the sync event. However, it seems like that doesn't work for models.
So, how do I know when my model is done…

Stephanie Gredell
- 168
- 3
- 13
0
votes
1 answer
Backbone Model Save: sending fields as "model" subobject
User Model
define(
[
'backbone'
],
function (Backbone) {
return Backbone.Model.extend({
url: '/proxy.php/users.json',
defaults: {
'first_name': '',
'last_name': '',
'work_email': ''
},
…

azz0r
- 3,283
- 7
- 42
- 85
0
votes
1 answer
Backbone.js - Is it need to keep, all my web page contents as a separate Model and View for them..?
In my simple page, I have 3 portions (tittle, paragraphs, links - image attached ) is it all 3 portions need to have a separate model for each of them..?
or i can make a single model for all of them.. which is correct way...
Again, in case in my…

3gwebtrain
- 14,640
- 25
- 121
- 247
0
votes
2 answers
Binding of a Collection nested inside a Model
I have this model structure in my mind:
var app = app || {};
// Caratteristica
app.Attribute = Backbone.Model.extend({
defaults: {
name: '',
selected: false
}
});
app.Attributes = Backbone.Collection.extend({
…

Fabio B.
- 9,138
- 25
- 105
- 177
0
votes
1 answer
How can I make a collection from a backbone models attribute?
In our backbone app, we have a profile model. It has an attribute "completeness" that is an array containing the fields the user has not added to their profile (like profile picture, full name, etc).
In order to easily do listenTo on this array,…

Martin Josefsson
- 953
- 12
- 24
0
votes
1 answer
How to update backbone model from database
I am creating a webpage to show the listing from my database table,
suppose my database table is updating in every 10 second from my php cron , then i want to sync my backbone model/collection whenever my database table get update from my php…

user562451
- 65
- 1
- 8
0
votes
1 answer
Backbone.js error callback parameters getting replaced with model
I have a RESTful JSON api that I use to perform server-side calls like this:
Servlet.prototype.ajaxJSON = function (jobject, func, context) {
var self = this;
$.getJSON(this.name, jobject, function (json) {
...
…

brokethebuildagain
- 2,162
- 1
- 22
- 44
0
votes
1 answer
Can I query the server with a Backbone.js model?
My model looks like that:
var Item = Backbone.Model.extend({
urlRoot: '/item/ajax_get'
});
If I want to get a specific item from the database, I can do: item = new Item({id: 11});
But what if I don't know the id of the item that I want to…

Shamoon
- 41,293
- 91
- 306
- 570
0
votes
1 answer
How to trigger an event only after id is assigned to backbone model after save() method
I am using backbone model in my application but the problem is that I want to perform some function after id is assigned to newly created Model. I am using this
activeWidget.on('sync', this.addToCollectionWidget(activeWidget));
But…

ali asad
- 1,329
- 4
- 17
- 23
0
votes
1 answer
In BackboneJS, clarification on setting the attributes of models
Two common scenarios when I am using backbone backbone:
Attribute is listed as default value, then set
modelExample_A: Backbone.Model.extend({
defaults: {
whatever: 'foo'
something: 'blah'
}
});
viewExample_A: Backbone.View.extend({
…

AlexZ
- 11,515
- 3
- 28
- 42
0
votes
1 answer
Backbone - Uncaught TypeError: Object [object Object] has no method 'call'
I am trying to save a model, I can save the first model fine, however if I save one model and then another straight afterwards - I get the following error,
Uncaught TypeError: Object [object Object] has no method 'call'
What would be causing this…

Udders
- 67
- 2
- 9
0
votes
2 answers
model.save - saves to the server only once
I am running this code in backbone which saves some data to the server,
GroupModalHeaderView.prototype.save = function(e) {
var $collection, $this;
if (e) {
e.preventDefault();
}
$this = this;
if (this.$("#group-name").val() !== "")…

Udders
- 67
- 2
- 9
0
votes
1 answer
Using backbone.js model concept without views/routing
i would like to go for a step-by-step migration of my existing "serverside rendered" webapplications to a more "cientside rendered" approach.
my preferred starting-point would be to change the existing data-handling layer towards an ajax style…

engulfing
- 11
- 3
0
votes
1 answer
json parsing in backbone
I have a success callback function which returns the following always :
{"ss":0,"me":"Invalid Username or Password"}
success :function(result){
console.log("RESULT : "+result.ss);
}
But this always ends up as undefined.. If i print the…

Roy M J
- 6,926
- 7
- 51
- 78