Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
0
votes
1 answer
Error retrieving models from backbone collections once there is idAttribute = '_id'
I have a Model user set to be like this:
User = Backbone.Model.extend({
urlRoot: '/users',
defaults: {
id: '',
username: '',
password: ''
},
idAttribute: '_id',
initialize: function () {
…

benjaminz
- 3,118
- 3
- 35
- 47
0
votes
1 answer
Backbone.Model destroy does not includes model ID in url
I want to use a delete method for my backbone model but for some reason, backbone does not include that model ID in produced request URL. To remove my model, i need to fire a following request: DELETE /api/v1/places/12/place_users/12. Here is my…

mbajur
- 4,406
- 5
- 49
- 79
0
votes
2 answers
How to add Backbone Model global function
I need to add a function for all my models, but I can´t do how to recognize the model as "this" scope variable. My function will do my model can be reseted to the defaults and by some data-object as parameter:
Backbone.Model.prototype.reset =…

Brian
- 349
- 1
- 5
- 16
0
votes
1 answer
Backbone fetch from API models not being set correctly
Hello I have some functionality in my backbone application, that allows the user to make a selection via a select menu and that choice fires a get request, the response is added to a collection,
this.archived.fetch({
success:function() {
…

Udders
- 6,914
- 24
- 102
- 194
0
votes
0 answers
Using RequireJS inject additional Bacbone Models in View
I'm learning Backbone with RequireJS and I have got a problem when trying to instantiate additional model in my view. I have couple of events which are calling different methods. Different methods are using more or less different models and subviews…

fefe
- 8,755
- 27
- 104
- 180
0
votes
2 answers
Get same Item collection but with different limits
In my Backbone project, I am getting a collection of Items through the following Model:
MyApp.models.Items = Backbone.Model.extend({
url: "getItems"
});
and then later:
var model = new MyApp.models.Items();
model.fetch().then(function(data){
…

Mr_Green
- 40,727
- 45
- 159
- 271
0
votes
1 answer
Backbone Collection communicating with Backbone Models
I'm trying to understand what the best practice is for communicating between the different components of a Backbone project. I've been re-implementing the Backbone version of TodoMVC and my question is around removing models from the collection…

wmock
- 5,382
- 4
- 40
- 62
0
votes
1 answer
keep changed attributes after change event
Is there a way to prevent backbone from clearing out the changedAttributes object after changing a property (backbone version > 1).
I simply try to increment a version attribute of a model when the model has changed after adding some data and then…

Macs
- 197
- 2
- 15
0
votes
1 answer
Nonconventional api requests with backbonejs (such as get by email)
I am building a backbonejs client, but to populate the models, I do not know the id to request from the server. Instead, I only have the email address attribute.
The API has an endpoint like v1/people/:email_address, and I'd like to use that to…

johncorser
- 9,262
- 17
- 57
- 102
0
votes
1 answer
Sorting models in a backbone collection strange behaviour
In backbone application I have the ability to sort a collection of models in ascending or descending order based on a couple of attributes, one of which is cost.
The api I am using weirdly returns the cost a string (not sure why I am investing…

Udders
- 6,914
- 24
- 102
- 194
0
votes
2 answers
Custom Backbone.Model action not working
Based on a lot of resources found on the internet, i'm trying to create my custom model action which sends a POST /api/v1/users/subscribe request. My code looks like this:
@UserModel = Backbone.Model.extend
urlRoot: '/api/v1/users'
subscribe:…

mbajur
- 4,406
- 5
- 49
- 79
0
votes
2 answers
Backbone model which I see in success callback and error callback is different. #Backbone save
I have a backbone model which has Backbone Collections in it. When I save the model and if it is success then my model object is properly structured as it was. But when error occurs (say validation error), in error callback the model object is…

ashy143
- 169
- 11
0
votes
0 answers
Backbone model includes random methods and attributes
I have an backbone application that collects data from an api the data from the api looks like this,
{
"id": "117",
"name": "Another new organisation",
"slug": "another-new-organisation",
"information": "",
"type":…

Udders
- 6,914
- 24
- 102
- 194
0
votes
0 answers
Backbone models not always setting the correct data
I have a backbone model that is mix of single attributes, other models and collections.
To create this model and collection within a parent model scenario my model code looks like this,
App.Models.Project = Backbone.Model.extend({
urlRoot:…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
backbone model and collection
help me understand why the code is not working properly
my code:
var Link = Backbone.Model.extend({
defaults : {
groups: []
}
});
var LinkCollection = Backbone.Collection.extend({
model:Link,
url: 'item.json'
});
var Group…

Andrey Makarov
- 3
- 1
- 2