简体   繁体   中英

Is there a way to bind an event to all nested models with Backbone and/or Backbone-Relational?

I have a pretty beefy BackboneRelational - model that has numerous nested models and collections. Basically if the user changes anything about this model or it's sub-models/collections, I need to do something in the UI to indicate this. So I'd like a master change event that would fire no matter sub-model changed. Is there an easy way to do this? I wrote a function that recursively traverses all of my models and adds a change events but I have problems with binding to the same model twice, race conditions, etc..

You can do by using Backbone.Events. var object = {};_.extend(object, Backbone.Events)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM