Questions tagged [backbone-model]

Models in the Backbone.js library.

Docs

325 questions
2
votes
2 answers

Update a model but persist the whole Backbone collection

My API response: { firstName: '', lastName: '', notifications: [ { category: '1', subcategory: '', source: '', optInDate: '', optOutDate: '', active: '' }, { category: '2', …
2
votes
1 answer

Using Backbone Relational to handle JSON-API Data

We've been using Backbone Relational to model our ORM relationship in the front end for instance: { id: 2 username: "bob" comments: [ { id:5, comment: "hi", user: { username: 'Bob' } } …
user391986
  • 29,536
  • 39
  • 126
  • 205
2
votes
1 answer

Model not being pushed into collection of backbonejs

jsfiddle I'm trying to create a message client using this tutorial at this point, the view is supposed to be updated when a new message is typed into the field and the add button is clicked. For some reason the "addMessage" Event is failing to add a…
2
votes
1 answer

BACKBONE/JS Best Practice: Is it good or bad to initialise a model inside view?

My Backbone.View looks this way: define(["promise!table_config", "BBModel"], function (config, myModel) { "use strict"; return Backbone.View.extend({ initialize: function () { this.model = new myModel({ …
2
votes
2 answers

Why does Backbone's collection create() method not populate the id?

In my view's method below, my model gets synced with the server if I understand the create() method properly. However, the console.log of this.model.id still returns undefined and this.model.isNew() returns true. The POST shows an id in the return…
2
votes
1 answer

Backbone Model object passed between Alloy controllers have null properties

I've started using titanium yesterday and i'm using the 'Creating your first titanium app' tutorial (this one). When it gets on the part that you click on a row and it opens another view, my argument values are null. Here's my…
Joao Victor
  • 1,111
  • 4
  • 19
  • 39
2
votes
3 answers

backbone validate single attribute in save only

I have one model with 2 attributes. Let me explain first. Backbone.Model.extend({ validation: { username: [ {required: true, msg: 'Enter email/username.'}, ], password: [ …
Manish Sapkal
  • 5,591
  • 8
  • 45
  • 74
2
votes
2 answers

Why / When I should use the Backbone-relational framework

I got a confusion sate now, any one clear my doubt and give more details about http://backbonerelational.org/ please? basically, Why we use the relational When we need to take a decision to use that Can't we achieve the same with Backone.js…
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
2
votes
1 answer

Proper way of populating Backbone Collection

I have the following Backbone Model and Collection /** * DataPoint */ var DataPoint = Backbone.Model.extend({ defaults: { ts: null, value: null } }); var DataPointCollection = Backbone.Collection.extend({ model:…
leonsas
  • 4,718
  • 6
  • 43
  • 70
2
votes
1 answer

Backbone view based on model from collection, how to update view?

I am looking for a bit of direction I am still fairly new to Backbone and am currently creating a test application to learn more. My problem is this, I am populating a backbone view with a underscore template. I load a collection of models, then I…
2
votes
1 answer

Backbone model is destroyed even on service error

I'm trying to destroy a backbone model and it gets destroyed even on a service error. View : this.listenTo(this.collection, 'remove', function() {}); this.model.destroy({ success : function(model) { /* remove the li view */ }, …
user1184100
  • 6,742
  • 29
  • 80
  • 121
2
votes
0 answers

No requests made when saving/creating Backbone model

This is stumping me... whenever I do model.destroy() the request goes through successfully and the model gets deleted. However, whenever I try to model.save() or collection.create(this.model) no requests are being made to the server for some…
Sayem Khan
  • 532
  • 7
  • 21
2
votes
1 answer

Backbone - How to this.model.save() an attribute with array?

I have this model: var Contact = Backbone.Model.extend({ defaults: function () { return { idc: "" name: "" email: "", phones: new Array() } }, urlRoot:…
Bruno Almeida
  • 166
  • 3
  • 14
2
votes
1 answer

Backbone.js: set a model property within the model?

Working in Backbone.js, I'd like to set a model property from within a method on the model. This seems like it should be simple, but I can't get it to work. Currently what I have is this. I'm trying to set the 'results' property during a call to…
Richard
  • 62,943
  • 126
  • 334
  • 542
2
votes
1 answer

PUT and POST requests in Backbone.js

I have another question related to the PUT and POST requests. So, here I have a form which has the fields like : "name" and "link". On submit of that form, I am not able to post that form to the server on doing this.model.save(); Also, how do I…
Sudo
  • 559
  • 1
  • 8
  • 15