it is important to note that you can't listen to associated model changes just by having
You need to listen to this.on('change:associatedModel', callback)
Can you please give an example or a jsfiddle - which demonstrates the problem you are facing? See this particular test case (highlighted in yellow) which does both change and change:AssociatedModel
here is the jsfiddle : http://jsfiddle.net/GV4Tq
I'm talking about the case where you do :
Thanks for clarifying. This is deliberate. The rationale for introducing fully qualified paths was that the path would give you info about which node in the hierarchy has changed and you could get the info about the changed node through the event arguments.
We had deliberated about introducing the global change event - at higher levels of the object graph - a couple of times, but settled for fully qualified paths at the end. While it is not difficult to add the change you want, there are some concerns
It would lead to a proliferation of events. In a deeply nested model, for each layer you would have to introduce at least 2 new events : change + change:attribute-name where attribute-name would not be a fully qualified path, but an immediate attribute of the node at that level.
We would have to simulate the events mentioned in pt#1. When you change an attribute in product, you are not really changing the memory reference to product in item. Consequently we cannot delegate (leverage) Backbone base infrastructure to treat it as a change event. Which means we would have to write more custom code and the compactness of the implementation suffers.
We wouldn't want these events to bubble up the hierarchy beyond one level. As it would lead to potentially duplicate events. (As they would also get converted into fully qualified event names at higher levels)
Nonetheless, I will update the pitfalls section of the documentation to make this explicit.
I have updated (4324af7) the pitfalls section of the documentation and cross referenced this issue. I am glad to hear that the extension is useful to your work. If it's possible, do share a URL. I can put up a usage list if I hear from other folks as well. And yes, don't forget to star us if you like the extension!
Introducing 'nested-change' to avoid pitfall #2 (issue #28)
With BB-Associations v0.5.0+, you can now use the nested-change event for global events. See your revised fiddle here. For rationale, you can see the nested-change section in the event catalogue documentation.
I just test your last fiddle example using "nested-change" event and it does not work (i use v0.6.2)