Backbone を初めて使用するので、ベスト プラクティスを知りたいです。子から親ビューと通信する簡単な方法、つまり親のメソッドを呼び出す方法が必要です。
「デスクトップ」ビューと「ドキュメント」ビューを使用した以下の基本的な例:
class DesktopView extends Backbone.View{
constructor(options?) {
super(options);
this.el = $('#desktop');
this.createDocument();
}
createDocument() {
dv = new DocumentView();
$(this.el).append(dv.render());
}
}
class DocumentView extends Backbone.View{
constructor(options?) {
super(options);
this.tagName = 'div';
this.className = 'document';
this.events = {
"click": "clickHander"
};
};
render() {
return this.el;
}
clickHandler() {
//COMMUNICATE WITH THE DESKTOP VIEW
}
}
ドキュメント ビューのモデルを作成し、その変更をリッスンする必要がありますか?