Models in the Backbone.js library.
Questions tagged [backbone-model]
325 questions
0
votes
1 answer
Get the changed "this.model" attribute value
A Backbone.js noob question. The code I'm working with currently looks like this
My DataModel Model :
define(['jquery', 'underscore', 'backbone'], function($, _, Backbone) {
var DataModel = Backbone.Model.extend({
// Defaults attribute…

shabeer90
- 5,161
- 4
- 47
- 65
0
votes
1 answer
Detecting a model being deleted from a collection backbone
I am working on a backbone app at the moment, and I have hit a bit of wall. I have collection that looks like this,
r {length: 3, models: Array[3], _byId: Object, constructor: function, model: function…}
_byId: Object
_events:…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
Backbone View - not finding the $el, after Model triggers
I am doing a simple validation for my username and password. My Model is here:
define(["backbone"], function(Backbone){
var LoginModel = Backbone.Model.extend({
url:'/home',
defaults:{
userName:'',
…

3gwebtrain
- 14,640
- 25
- 121
- 247
0
votes
2 answers
Listen to changes periodically in backbone.js
Experience: Newbie
I have initialize function like this
initialize: function(){
this.listenTo(this.model, "change", this.asyncRender);
}
I want to listen to changes periodically,like for every 5 sec
I want something like…

Sasikanth
- 3,045
- 1
- 22
- 45
0
votes
1 answer
Backbone possible to merge data?
In a backbone application I am writing I need to combine 2 sets of data into one,
I have the following in my initialise function for a view,
this.model.set('tasks', new Tasks(this.model.get('item_tasks')), {
silent:…

Udders
- 6,914
- 24
- 102
- 194
0
votes
1 answer
How to cast collections with subcollections in backbone.js
I am trying to retrieve my model from a JSON that has arrays with sub arrays and I am getting crazy. The objects get populated but not with the Models expected. I manage to make those from first level work fine, but the trick doesn't seem to work…

Fabiot
- 429
- 1
- 4
- 13
0
votes
1 answer
Backbone.js model trigger change only if model.on called again
It's my first post here so please be nice ;) I'm trying to create a Backbone+requireJS sample app and I have stumbled upon a strange problem. In my views initialize function I bind to models change event by
this.model.on("change",…

user3485150
- 3
- 2
0
votes
1 answer
How to update the view without rerendering on BackboneJs?
I'm trying to do the obvious, update the view on model change (in this case a new one is added).
It actually works, but the problem is the whole view gets rerendered when a model is added.
The new data is actually not really being appended to the…

user254883
- 599
- 1
- 5
- 14
0
votes
1 answer
How to sort collections in backboneJs
im learning BackboneJs using the documentation and a book called "Beginning backbone".
But I have been stuck at the sorting collections part for hours.
Also tried to research but I find the results complicated =/
I know I have to use the comparator,…

user254883
- 599
- 1
- 5
- 14
0
votes
1 answer
Backbone model is plain text file. How to fetch?
I have a model File which contains a plain text file. For example Github Gists have this url structure: https://gist.githubusercontent.com/140bytes/962807/raw/dfb480a5038214d152544bddb412dfe2e8656413/LICENSE.txt.
To do this, should I override…

000
- 26,951
- 10
- 71
- 101
0
votes
1 answer
backbone.stickit and html-form: How to save (patch) only changed attributes?
tl;dr
How to use backbone.stickit with a html form to change an existing model fetched from the server and only PATCH the changed attributes (changed by user input within the html form) to the server?
/tl;dr
I'm using backbone.stickit in a…

morten.c
- 3,414
- 5
- 40
- 45
0
votes
1 answer
Updating a variable attribute with backbone's set method
I need to update one attribute of a model after an event has been triggered from the view. I do not know which attribute will have to be updated beforehand. How can I set a variable attribute with backbone's set method?
Here is an example set of…

CrackerKraken
- 59
- 8
0
votes
2 answers
How to discard/reject an extra attribute in Backbone Model initialize()
I have a problem while initializing a Backbone model with some data coming from Jackson.
The received data happens to have a listPropertyValue, which is originally a Java List of objects. When doing the initialize() method I make it a Backbone…

madtyn
- 1,469
- 27
- 55
0
votes
3 answers
Getting specific Backbone.js models from a collection without getting all models first
I'm new to Backbone.js. I'm intrigued by the idea that you can just supply a URL to a collection and then proceed to create, update, delete, and get models from that collection and it handle all the interaction with the API.
In the small task…

Swisher Sweet
- 769
- 11
- 33
0
votes
1 answer
Setting 3rd Level Nested Attribute on a Backbone Model
I'm having trouble changing the location $id on this Backbone model.
{
"approved": null,
"caption": "This is my photo!",
"created": 1393537913,
"location": {
"_id": {
"$id": 5
},
"address1": "155 West…

ztnark
- 329
- 1
- 2
- 10