How deep can I attach spinal change events?

Let's say I have a (rather funny) model of a book that ascribes something like:

page:{ paragraph:{ wordcount: { the: 8, at: 10 } } } 

Is it possible to bind very nested values ​​to a change like this?

 book.on("change:page:paragraph:wordcount:the", ...); 
+6
source share
1 answer

The trunk fires change events for top-level attribute names. To Event Catalog :

  • "change" (model, parameters) - when changing the attributes of the model.
  • "change: [attribute]" (model, value, parameters) - when updating a specific attribute.

There is no mention of any nesting. In fact, if you change the attached property of an attribute, I am sure that it does not even trigger an event (since the attribute itself has not changed). Also, if you look at the annotated source (although the factors that influence this behavior are a bit split), you can follow it to where the change:attribute events fire .

However, it looks like a plugin is there to help you with what you need.

+5
source

Source: https://habr.com/ru/post/914659/


All Articles