Listen for changes on a related object AND it's attributes
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: http://codepen.io/jackocnr/pen/rgawc
I've just realised a workaround is to manually trigger a change event on the event model: this.model.trigger("change");
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: http://codepen.io/jackocnr/pen/jBvFL
I just noticed the same issue. Is there a known work around?