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

3
  • Take a look at this question answered by @Derick Bailey: stackoverflow.com/questions/7843278/… -- 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, 2011 at 14:08
  • @Brian Tompsett - 汤莱恩 this question isn't about dom-events, backbone has it's own event system
    – T J
    Oct 29, 2019 at 12:22
  • @TJ Thanks for the heads-up. I'll watch out for that. Oct 29, 2019 at 18:20

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.