Skip to content

Listen for changes on a related object AND it's attributes #363

jackocnr opened this Issue Jun 14, 2013 · 2 comments

3 participants


I have an event model with a HasOne relation to a location model. On my edit event form, that location field can "change" in two ways: it's attributes can be tweaked (e.g. update the "name" of the location), but also the whole model can be replaced by another (selecting from a list of previous locations). The problem arrises with the event preview I am displaying in another View - how do I listen for both types of changes?

Currently you can do:
this.listenTo(this.model, "change", fn);
this.listenTo(this.model.get("location"), "change", fn);

But then the second listener stops working when you change the location model:
this.model.set("location", anotherLocation);

CodePen here:


I've just realised a workaround is to manually trigger a change event on the event model:

Update: No, this only seems to work if you change the event location to another model first. If you update the existing location model's attributes, the manual trigger doesn't do anything:


I just noticed the same issue. Is there a known work around?

@bpatram bpatram added the enhancement label Mar 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.