Say I have a (rather ridiculous) book model who attributes look something like:
page:{
paragraph:{
wordcount: {
the: 8,
at: 10
}
}
}
can I bind to change of very nested values like so?
book.on("change:page:paragraph:wordcount:the", ...);
Backbone only triggers change
events for top-level attribute names. Per the Catalog of Events:
- "change" (model, options) — when a model's attributes have changed.
- "change:[attribute]" (model, value, options) — when a specific attribute has been updated.
There's no mention of any nesting there. In fact, if you do change a nested property of the attribute, I'm pretty sure it won't even trigger an event (since the attribute itself didn't change). Additionally, if you look at the annotated source (although the factors affecting this behavior are a bit split up) you can follow it down to where change:attribute
events are triggered.
However, it does look like there's a plugin to help accomplish what you're after.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With