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

stop model change events propagation #123

Closed mohamedfarouk closed 10 years ago

mohamedfarouk commented 10 years ago

i have noticed that nested objects change events are fired and handled first, but in some cases i needed to handle events on each level so if i have handled the most inner value change event need to stop the event in the outer levels ie if this event fire user.bind('change:name.middle.initial', function(model, newInitial){ ... });

need to have the ability to stop the subsequent events

user.bind('change', function(model, newVal){ ... }); user.bind('change:name', function(model, newName){ ... }); user.bind('change:name.middle', function(model, newMiddleName){ ... });

afeld commented 10 years ago

The order that the events are fired isn't guaranteed, and I could imagine a lot of variations of this that people would want. I'd recommend adding the conditions you need within your app. You could try extend()ing Backbone.NestedModel and overriding trigger().