Questions tagged [backbone-model]

Models in the Backbone.js library.

Docs

325 questions
0
votes
1 answer

Backbone Models: defaults based on a condition

I'm pretty new to BackboneJS, looking for some help in the defaulting an attribute based on a condition How can I default name to TEST based on a condition that is only if model.attribute = 'xyz' in Backbone models. defaults: function() { return…
InquisitiveGirl
  • 667
  • 3
  • 12
  • 31
0
votes
1 answer

Titanium / Backbone: Ensure that a property on a model always has it's type converted

I have a Titanium/Appcelerator app created using Alloy models, which uses Backbone.js. Each model has a text field that I would like to interpret as a number. So far I've been getting the property and converting it using parseInt() each time I need…
shrewdbeans
  • 11,971
  • 23
  • 69
  • 115
0
votes
2 answers

Single server call during backbone view rendering when multiple views are sharing same model

I have a multiple instances of a view which share single instance of model among themselves. During rendering of view, I want to call a function inside model which makes server call to fetch some data only once. As these views are instances of…
0
votes
1 answer

check for model attribute before fetch

I have this line of code in my method in a backbone router. $.when(system.sideEngine.fetch(), system.lifeSupport.fetch()).done( ... It works fine if the system has a sideEngineId and a lifeSupportId. However if either id is missing, I get a 404 not…
SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185
0
votes
1 answer

How to skip parse function call in backbone model while calling fetch

I have a backbone model which has custom parse function, while calling the fetch on this model sometimes I wanted to skip the parse function in certain scenarios. How can I do it. I tried the following option which did not work. myModel.fetch({ …
0
votes
1 answer

How to query nested object of a model in backbone using .where()

I have collection name @collection. Each model of @collection looks like this: { name : "example", layout : { x : 100, y : 100, } } I have to do find models where model.attributes.layout[x] == '100'. Can I do something like this…
0
votes
3 answers

Backbone model fire only one change

When you create a Backbone model and attach a change event, it will listen for it. And event if you change them at the same time (in the same set call) it will fire the change event the number of changes you have in your model. So imagine I have a…
0
votes
1 answer

conceptual backbone nested collection

I am using backbone with Node and Express. I have my restful api set up to return my model and collection data. The api works fine. But I'm having trouble binding a route to one of my api paths. I have a company model and collection so that when…
mo_maat
  • 2,110
  • 12
  • 44
  • 72
0
votes
1 answer

add updated model into Backbone Collections

I used collection create method to save the model into the server. But this create method automatically adds the stale model into the collection. I am trying to do the following things. After the inserting process success, I would like to add…
user1156041
  • 2,155
  • 5
  • 24
  • 54
0
votes
0 answers

Backbone model collection with nodejs/express

Would like to know if anybody used Backbone model, collection in nodejs . My app is totally dependent on API and would like to use Backbone in current setup. If anybody knows existing example please share. I'm also open for other solutions.
0
votes
1 answer

Backbone.js / require.js - Override model function to work with backend as a service

Good morning guys. I have a little understanding problem with backbone.js. i have a javascript sdk from a backend as a service with some getter and setter methods to get datas from this platform. I have load this javascript sdk with require.js an…
0
votes
1 answer

Backbone Model urlroot

These are the path url's that my server has: GET /watchlists GET /watchlists/:id POST /watchlists // Create a new watchlists PUT /watchlists/:id // Change attributes of watchlists (Like name) POST /watchlists/:id/movies // Add a movie DELETE…
0
votes
1 answer

retrieve nested attributes in model

For the life of me, I can't figure out how to get a few attributes in my model. I define my reportUrl model like this: var ReportUrl = Backbone.Model.extend({ urlRoot: '/api/report/test/' }); then in my view, I fetch it like this, and…
SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185
0
votes
0 answers

How to use Global accessible object in BackboneJS

I want to use an object globally in Backbone Application. I was using jQuery MObile Application before. To have a global variable, I created a file named Configuration.js which have the scripts, var MyApp = MyApp || {}; MyApp.Configuration =…
0
votes
0 answers

Backbone - Have a view load its own model?

In most Backbone examples I've seen, the creator of a view also creates the model or collection and then binds it to the view when it is initialised. For top level views that will always render the same model, is it bad practice to have the view…