Questions tagged [backbone-relational]

Get and set relations (one-to-one, one-to-many, many-to-one) for Backbone models.

Get and set relations (one-to-one, one-to-many, many-to-one) for Backbone models.

Resources:

256 questions
4
votes
1 answer

change event in backbone relational not working

I am working with backbone relational with HasMany relationship. Add event gets fired but change event does not. Model1 = Backbone.RelationalModel.extend({ urlRoot: '/Leve1/', initialize: function () { this.listenTo(this,…
Umesh
  • 41
  • 2
4
votes
2 answers

Backbone-Relational find or load?

The model caching within Backbone-Relational is very good, but to load a simple model safely requires quite a bit of code. E.g. // Try and find a model in the Cache this.model = MyModel.find({id:id}); if(this.model){ // Model loaded from cache,…
DigitalJohn
  • 281
  • 3
  • 12
4
votes
1 answer

Example for Backbone-relational with Marionette views

I've just recently stared using backbone.js and since i have a rather large data-structure, i am using backbone-relational in order to keep it as lean and as fast as possible. Now i would like to use marionette views, but i've been struggling to get…
4
votes
1 answer

Backbone-relational submodels with RequireJS

I'm trying to find a way to use Backbone-relational submodels with RequireJS, where the submodels are in different files than the supermodel. For example: // app.js define(function() { var app = {}; var app.ns = {}; …
Andrew Ferk
  • 3,658
  • 3
  • 24
  • 25
4
votes
1 answer

How to auto-create many-to-many relations from initial JSON with Backbone Relational?

The example from docs about many-to-many relationship supposes that companies would be added after the person was already created. However, what if the person data comes from server with a list of companies (companies' ids) already? Is it possible…
Georgii Ivankin
  • 2,702
  • 2
  • 23
  • 35
4
votes
1 answer

How do I load sub-models with a foreign key relationship in Backbone.js?

Sorry if this is a bit convoluted... I am still learning Backbone.js... What is the proper way to load & save Backbone models that have sub-models within themselves? (And should I even be having sub-models?) For example, (pardon the coffeescript),…
Adam Morris
  • 8,265
  • 12
  • 45
  • 68
4
votes
0 answers

Backbone-relational: remove an element of a nested array attribute from localstorage

I have a RelationalModel "Todo" which "HasMany" comments (nested array). How do I remove a particular comment from this nested collection? It would be great if someone could provide also examples how to add (and update) a "comment" to this nested…
genericatz
  • 433
  • 5
  • 16
4
votes
1 answer

When to call Backbone.Relational.store.unregister() when using complex model structures

I've got an app build using Backbone Relation that is leaking memory like crazy. From what I understand this is because I am never calling Backbone.Relational.store.unregister() on my models, causing them to be kept in the store forever and…
Stefan Fisk
  • 1,563
  • 13
  • 19
4
votes
1 answer

Serializing/Deserializing nested Backbone Relational models to JSON

Given the following RelationalModel model: var Server = Backbone.RelationalModel.extend({ relations: [{ type: Backbone.HasMany, key: 'databases', relatedModel: 'Database', collectionType: 'DatabaseCollection', …
4
votes
1 answer

Backbone relation: how to put in relation collection and model?

I have the following situation and I think the best way to deal with it is to use Backbone relation. Please correct me if there is another solution. I have one collection (1) and one model (2). The collection result looks like (3) and the model…
js999
  • 2,063
  • 4
  • 26
  • 34
4
votes
1 answer

Using Backbone-relational with CoffeeScript

I'm trying to use a Backbone-relational and CoffeeScript in a project.The following is an example in CoffeeScript of the type of things I'm trying to model : class NestedModel extends Backbone.RelationalModel defaults: Description: 'A…
Simon Lomax
  • 8,714
  • 8
  • 42
  • 75
4
votes
1 answer

Backbone Relational not setting reverse relations properly?

I'm trying to use Backbone.Relational to set up some associations in my app. Basically I have Backbone Search and Service models. A Search has a ServiceList collection which contains many services. However, I don't seem to be able to access the…
David Tuite
  • 22,258
  • 25
  • 106
  • 176
3
votes
1 answer

Backbone.js relations

I'm having an issue wrapping my head around relational models in Backbone. I've just started using it and I'm tasked with a fairly large application. The main issue I'm having is that I have a model that should contain a collection. This is what I…
MikeD
  • 123
  • 4
3
votes
1 answer

Is there a way to bind an event to all nested models with Backbone and/or Backbone-Relational?

I have a pretty beefy BackboneRelational - model that has numerous nested models and collections. Basically if the user changes anything about this model or it's sub-models/collections, I need to do something in the UI to indicate this. So I'd like…
3
votes
1 answer

defining relationships in Backbone-Relational -- not sure which direction the options are pointing?

I'm having a heckuva time understanding the documentation for Backbone-Relational; it's not 100% clear on which relation to add things like includeInJSON. Probably best to describe my confusion by illustrating the structure I'm trying to create. I…
1 2
3
17 18