Questions tagged [backbone-model]

Models in the Backbone.js library.

Docs

325 questions
1
vote
2 answers

Appending new data to the Backbone Relational Relation

I'm trying to design a load more type of system where every time you press load more you add data to the existing collection. This is a rough sketch of how the UI looks. Everything works pretty great except as you would except everytime I re-run the…
1
vote
1 answer

backbone fetching a model returning strange data

I am fetching model data from my server like this in my backbone application, var projectModel = new App.Models.Project({ id: 1001 }); projectModel.fetch(); The fetch works and I get data back from the server, but the data is not in the format I…
Udders
  • 6,914
  • 24
  • 102
  • 194
1
vote
1 answer

Initialize Backbone Models based on another Backbone Model

I have a config.json that I am going to load into my app as a Backbone Model like: var Config = Backbone.Model.extend({ defaults: { base: '' }, url: 'config.json' }); Other models should be dependent on some data contained in…
lbrahim
  • 3,710
  • 12
  • 57
  • 95
1
vote
1 answer

backbone model.save() does not set the response body of the express server with body parser

I am trying to save (post) a Backbone model using a model.save(). Model: Backbone.Model.extend({ urlRoot: '/project/', defaults: { projectname: "default projectname" } }); Saving the model (in my Backbone.router object): putTest:…
1
vote
1 answer

Backbone view listening to model, not firing on change or reset?

I am using a model to fetch location data from a service using POST. However I am struggling to get the view to listen to that model when it finally receives a response. Note I have overriden some model methods to fit the service I am using. Model…
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
1
vote
0 answers

How do I test Backbone.Model's methods that delegate to $.ajax?

Backbone.js is working fine when I compile it with browserify, however I'm having a hard time testing my Backbone.Model's under Mocha. When I do I get, TypeError: Cannot read property 'apply' of undefined at Object.Backbone.ajax…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
1
vote
1 answer

Backbone Performance - Collection with a view per model or only one view for the whole collection

If a have a collection with 50 models, it seems that I have 2 main options to render a list displaying 50 models: - Option1 : Create a specific "item view" for each model and append these views to a main "list view". This will provide a direct…
1
vote
1 answer

Backbone.js Error when binding a model to a view

I´m new to Backbone.js, but after some research I still couldn´t find the source of my problem. I am developing an App and I have a collection of models, which I eventually want to display in a view (just one model at a time). Here´s my code so…
1
vote
2 answers

Generate custom Backbone error on model.save success

I am trying to override Backbone.sync method for my model. The server returns status : 200 OK and model fires success callback in all cases. The server response is as follows status: 200 OK response : { statusCode: '0'; // 0 success, 1,2,3…
1
vote
2 answers

Backbone.js - get view, model or collection property in ajax 'beforeSend'

I am using Backbone.js in my node app. I am calling various ajax call from views, models and colllection. I have created my custom property e.g. "myName" in every view, model and collection and assigned with unique name for each. Now I want this…
1
vote
3 answers

Backbone.js What is the purpose of specifying a model in collection

Here is what I am trying to understand. Often times I find myself writing backbone like this: var CallModel = Backbone.Model.extend({ }); var CallsCollection = Backbone.Collection.extend({ model: CallModel, url:…
1
vote
2 answers

Backbone.Model how to listen for changes on multiple attributes only once

Say I have a Layout model with width and height properties. And Say I want to update a view when either of them changes, but the updating process in computational intensive and requires the value of both width and height. The computation process…
Prinzhorn
  • 22,120
  • 7
  • 61
  • 65
1
vote
1 answer

Objects not being removed from collection in Backbone

this is the jsfiddle What am I trying to achieve? I'm trying to create a message client using this tutorial, I'm at the part where an object gets removed from the view. What happens when I click delete? For some reason the remove function gets…
user3531149
  • 1,519
  • 3
  • 30
  • 48
1
vote
2 answers

Backbone collection.where

I am retrieving a model from a backbone collection. var organisation = this.collection.where({ group_id : String(elm.data('groupid')) }); this returns a result as I would expect it too. I then when to do some getting and setting on that model, but…
Udders
  • 6,914
  • 24
  • 102
  • 194
1
vote
1 answer

Instantiate model from existing model in Backbone

What is the preferred way, if any, to instantiate a Backbone model from an existing model, assuming that the model to be instantiated is of a derived type of the existing model? The case I have in mind arises when dealing with nested models. For…
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126