afeld / backbone-nested

A plugin to make Backbone.js keep track of nested attributes - looking for maintainers! https://github.com/afeld/backbone-nested/issues/157
https://afeld.github.com/backbone-nested/
MIT License
443 stars 83 forks source link

Cannot change variable nested properties #126

Closed amankapur closed 10 years ago

amankapur commented 10 years ago
var foo = "apple";

var model = new Model({
    name: 'test',
    bar: {
      apple: 1,
      banana: 2
    }
})

model.set('bar[foo]', 'orange') fails. and so does model.remove('bar[foo]')

I understand that is tricky and is getting into string pramming limitations, but is there a simple workaround?

thanks

amankapur commented 10 years ago

get is easier model.get('bar')[foo]

gkatsev commented 10 years ago

Did you mean model.set('bar[' + foo + ']', 'orange')?

amankapur commented 10 years ago

(derp)