3

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..

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Chris
  • 455
  • 5
  • 10
  • Take a look at this question answered by @Derick Bailey: http://stackoverflow.com/questions/7843278/fire-an-event-from-one-view-to-another-in-backbone -- basically, this gives you a pub/sub pattern that you can publish any change from your models, and listen to those from anything else. – swatkins Oct 28 '11 at 14:08
  • @Brian Tompsett - 汤莱恩 this question isn't about `dom-events`, backbone has it's own event system – T J Oct 29 '19 at 12:22
  • @TJ Thanks for the heads-up. I'll watch out for that. – Brian Tompsett - 汤莱恩 Oct 29 '19 at 18:20

1 Answers1

0

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

sid
  • 9
  • 3