Closed ridgeBoy closed 10 years ago
What do you mean it crashes? Are you getting any errors? Can you post those? Also, what version of Backbone-Nested are you using along with what version of Backbone?
Ok, I'm using those libraries:
jquery-1.10.2.js underscore-1.5.2.js backbone-1.1.0.js backbone.mutators-0.4.1.js backbone.memento-4.0.1a.js workflow.js backbone-validation-0.9.0.js backbone-nested-1.1.2.js backbone-relational-0.8.7.js
I attach a capture of my desktop:
Backbone-Nested 1.1.2 isn't compatible with Backbone 1.x.
We're in the process of releasing 2.0 which will have backbone 1.x compatibility. Can you please test with that version? It's available in the master
branch.
Hi,
the result is the same (see attachment)
If you need the sources, I can send them to your email.
Best regards
That's weird since we have tests that pass correctly. Can you a working example on something like jsbin.com?
I don't know if this is correct because it's my first time at jsBin
Looks like you forgot to instantiate the model before using it. You had
var BuyerModel2 = Backbone.NestedModel.extend({});
and then you tried to use it but you didn't have:
var buyerModel2 = new BuyerModel2();
before you started using buyerModel2
.
Here's an updated jsbin that works: http://jsbin.com/EbaKaPiF/4/edit
That's it!!!!!!!! :+1: :+1: :+1: :+1:
I suppose it's a mistake from the book
Thank you very much!!!!!
No problem. Glad to help. Please open more issues if you get more problems.
Hi there,
I'm learning backbone throught the book 'Backbone.js cookbook' from Vadim Mirgorod, and I have some problems with add() and remove() methods from Backbone.nested.
What I am using is a Chrome browser to view a page, and this page has the following libraries:
The code that triggers the error is:
//this is ok var BuyerModel2 = Backbone.NestedModel.extend({ });
//this is ok buyerModel2.set({ 'name.title': 'Mr', 'name.generation': 'II' });
//this is ok buyerModel2.set({ 'addresses': [ {city: 'Brooklyn', state: 'NY'}, {city: 'Oak Park', state: 'IL'} ] });
//this is ok buyerModel2.set({ 'addresses[1].state': 'MI' });
//this is ok buyerModel2.get('addresses[0].state'); // NY buyerModel2.get('addresses[1].state'); // MI
//this crashes buyerModel2.add('addresses', { city: 'Seattle', state: 'WA' });
buyerModel2.get('addresses[2]');// { city: 'Seattle', state: 'WA' }
//this crashes buyerModel2.remove('addresses[1]');