Quick sample of how to set/trigger nested Backbone.Model attributes

added by codeforcoffee
12/1/2014 6:37:46 PM

153 Views

I just wanted to chime in with a homemade solution for anyone who is using vanilla Backbone but needs a way to set nested attributes (ie: model.attributes.some.item.here) and listen for them via the model.on("change:some.item.here") listener. Essentially, you just create a new method in the model declaration that will generically let you update attributes while triggering them so you can utilize model.on("change:my.nested.attr");


0 comments