Questions tagged [backbone-model]

Models in the Backbone.js library.

Docs

325 questions
0
votes
1 answer

Using common model for view

We have written a base Backbone view class which abstracts the common methods and properties. All our view class in a module extends this base class. Also this classes use same model. The model contains a collection. I am listening to change event…
0
votes
1 answer

Fetching from Model has not supply the defaults

In my app, I am fetching the data from /home -by home Model. the Model contains the defaults object. But while i fetch the data, I am not able to see the default object in the model. here is my model : define(['backbone'], function(Backbone){ …
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
0
votes
0 answers

Server-side Backbone.Model?

I wanted to ask if anyone has tried to create a Backbone Model on the server? I appreciate Backbone is mainly for the client side and on a previous question about this no one recommended Backbone for the server... I'm not creating a MVC website or…
Pandafinity
  • 713
  • 2
  • 7
  • 19
0
votes
1 answer

Fetching a single model in backbone, why doesn't this work?

m is a subclass of Backbone.Model. I would expect m.url() to return '/api/media/sources/1' but instead I get: > m.id 1 > m.collection.url "/api/media/sources" > m.urlRoot undefined > m.url() "/api/media/sources" What's going on?
elplatt
  • 3,227
  • 3
  • 18
  • 20
0
votes
1 answer

Postpone Synchronize Backbone.js Collection with Server

I have a Backbone Collection that users are performing CRUD-type activities on. I want to postpone any changes from being propagated back to the server — the Collection.sync() should not happen until the user initiates it (like POSTING a form). As…
0
votes
1 answer

backbone.stickit not updating with model change

I have a backbone.sticket binding attached to a model associated with a mainView view: bindings: -> { ".some-class": "someAttribute", } and the following template
The attribute populates correctly, but…
fox
  • 5,569
  • 3
  • 16
  • 13
0
votes
1 answer

Backbone.Model: set collection as property

I'm new with backbone and faced the following problems. I'm trying to emulate some sort of "has many relation". To achieve this I'm adding following code to initialize method in the model: defaults: { name: '', tags: [] }, initialize:…
Ihor
  • 277
  • 4
  • 16
0
votes
1 answer

Update backbone model with new json

Right now, I'm passing json to model like this: model m = new app.SomeModel(json); and then using it, which seems fine. However, now whenever my json changes, I want to pass the new json to the model, without creating a new instance of the model,…
Saurabh Verma
  • 6,328
  • 12
  • 52
  • 84
0
votes
0 answers

Backbone model array attribute undefined

I have a Backbone model, which has the following attributes object, as output by console.log in Chrome: Object address: "testAddress" created_at: "2014-03-03 17:17:24" fpm_company_id: "1" group: null id: "3" maintenance:…
Tom Macdonald
  • 6,433
  • 7
  • 39
  • 59
0
votes
1 answer

Backbone.js - Cannot read property 'Model' of undefined

I've been following this tutorial: http://backbonetutorials.com/organizing-backbone-using-modules/ The error is for line 7 of home.js (Model). What am I doing wrong??? main.js // js/main.js require.config ({ paths: { // Include needed…
jstudios
  • 856
  • 1
  • 9
  • 26
0
votes
1 answer

Multiple Models using same View in Backbonejs

I'm a beginner in Backbone trying to get a sample page up and running with multiple instances of a Carousel. Here's how my HTML looks like
Ankur
  • 791
  • 4
  • 15
0
votes
2 answers

Get entire model in Backbone JS

In backbone javascript models, we get individual items as shown below: var type = this.model.get("type"); Here, type will be defined in server side & then fetched in JS using above syntax. My question is how do I get the entire model in one shot? I…
0
votes
1 answer

Backbone Model variable undefined after initialize

I have a problem with a backbone model variable being undefined even though I am sure it is initialized at some point. AreaOfInterest = Backbone.Model.extend({ defaults:{ marker: null, // center of the area area: null // area…
jlengrand
  • 12,152
  • 14
  • 57
  • 87
0
votes
1 answer

How to get collections in path using pattern matching?

collections: posts: -> # @getCollection('documents').findAllLive({relativeDirPath: 'posts'}, [date: -1]) @getCollection('documents').findAllLive({relativeDirPath: {'$in' : ['posts', /post\/[0-9]+/ ]}}, [date: -1]) In the main…
bguiz
  • 27,371
  • 47
  • 154
  • 243
0
votes
2 answers

Backbone Model: empty attribute with get method but in attributes object

I have these lines: console.log(JSON.stringify(this.model.attributes)); console.log(this.model.get('name')); And this is the output: "{"name":"ffg","key":"1c277f82-f093-d359-4cfb-febe4614a3b1"}" "" I'm starting with Backbone. Any ideas why the…
davibq
  • 1,089
  • 11
  • 31