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
1
vote
1 answer

How to deal with a collection nested in a RelationalModel?

I use Backbone-Relational to create a complex hierarchy of models, the code looks like this: var ModelA = Backbone.Model.extend({ initialize: function () { console.log('model a initialized!') } }); var CollectionA =…
heyun
  • 13
  • 2
1
vote
1 answer

Uncaught Error: Cannot instantiate more than one Backbone.RelationalModel with the same id per type

I'm using Backbone Relational in a Backbone Marionette app. If I follow this workflow: Navigate directly to the show page > click "Home" (or index page) link > click the browser's back button to go back to the show page I get an error which causes…
Tom Hammond
  • 5,842
  • 12
  • 52
  • 95
1
vote
1 answer

Backbone Relational - Uncaught TypeError: undefined is not a function

I have a BackboneRelational model defined in a file: define(function (require) { var Backbone = require('backbone'), BackboneRelational = require('backbone.relational'), StudentDetails = require('./StudentDetails'); var Classroom =…
1
vote
0 answers

Backbone-Relational with Marionette Require.js and SubModelTypes

I'm having this slight problem with Backbone-Relational when I try to create sub models inside the marionette module. Following backbone-relational documentation I have: Mammal = Backbone.RelationalModel.extend({ …
MikeWu
  • 3,042
  • 2
  • 19
  • 27
1
vote
0 answers

Backbone-relational-Model.subModelTypes with RequireJS modules

I'm trying to resolve circular dependency caused by the way to use (1) Backbone-relational Model's subModelTypes property and (2) RequireJS modules. I have defined super_model and sub_models in different files as require modules. I spent some time…
ykjs121
  • 385
  • 1
  • 2
  • 16
1
vote
3 answers

data modelling, how many fk should i use?

Let's say u have following architecture. User have many departments, (fk user_I'd) Each department HV many offices (fk department_I'd) Each office HV many transactions ( encounter s) (fk office_id ) Now question is, if I want to get all encounters…
Zalaboza
  • 8,899
  • 16
  • 77
  • 142
1
vote
0 answers

Backbone-relational: reverseRelation in HasOne-HasOne scenario is not working

I slightly modified an example from the docs, to create a reverse relation in HasOne-HasOne scenario (a Zoo contains an Animal, and the reverse relation on the Animal should point back to the Zoo). The problem is the reverse relation doesn't get…
xman85
  • 67
  • 1
  • 2
  • 8
1
vote
0 answers

backbone-relational: save creates new child-models which results in childviews being bound to orphaned child-models

I'm having a really hard time getting backbone-relational to work correctly. The problem is simple to understand (now I've tracked it down): on save of the parentmodel NEW child models are created from that point forward childviews that were bound…
Geert-Jan
  • 18,623
  • 16
  • 75
  • 137
1
vote
1 answer

Listen in Backbone view to nested Backbone Relational model events

Say I have a Backbone Relational model representing a crowd - it has a related collection of People, each of model type Person: CrowdModel = Backbone.RelationalModel.extend({ relations: [{ type: Backbone.HasMany, key: 'People', …
user888734
  • 3,797
  • 5
  • 36
  • 67
1
vote
2 answers

Backbone relational model saving error

I get the error, when I try to save the model with .save() Converting circular structure to JSON The funny thing is that modelInstance.toJSON() works just fine. The error is thrown at backbone.js line 1148 which is: params.data =…
Tibor Szasz
  • 3,028
  • 2
  • 18
  • 23
1
vote
1 answer

Backone relational subModelTypes

I’m using in my app awesome trio: Backbone + Backbone Relational + Marionette. Currently, I’ve got some troubles with creating polymorphic relation. Here is simplified version of code I’m currently using. class MyApp.Conversation extends…
user1105595
  • 591
  • 2
  • 8
  • 20
1
vote
0 answers

Backbone.js - Is my model is correct - in case of multiple level datas

I am getting json data from server for make the navigation menu (has the sublinks ) - for that, i am making my model as follow. is this correct..? any one help me please? Here is the json i am getting from server: [ { "label":…
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
1
vote
1 answer

Nested collection created as array instead of collection

I am having some trouble when I create a new model form json, with nested attributes that should be parsed as a collection. Here I show how I get to the error: (Any help appreciated) 1) I create a user like this user = new App.Models.User(…
tomasbarrios
  • 813
  • 9
  • 15
1
vote
1 answer

Error while using array of validator for a single attribute in backbone.validation

I am using two different messages for two different validation such as validation: { email: [{ required: true, msg: 'Please enter Email Id.' }, { pattern: 'email', msg: 'Please enter…
1
vote
0 answers

Collection contents deleted when view is closed

In my application, I have a CompositeView which wraps a cart-like object. When a user clicks an item, it is added to their cart, implemented like so: // app.js: app.main.show(new Cart({ collection: order.get('cart') }); ... // cart.js: var Cart =…
Mark
  • 1,312
  • 1
  • 16
  • 33