Tôi mới đến Backbone và tôi muốn biết một thực hành tốt nhất cho điều này - Tôi muốn một cách dễ dàng để giao tiếp với một cái nhìn cha mẹ từ một đứa trẻ tức là cuộc gọi một phương pháp trên phụ huynh.Backbone - gọi/tham khảo phụ huynh xem từ con xem
dụ thô sơ dưới đây sử dụng "desktop" và quan điểm "tài liệu":
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
}
}
Tôi có nên tạo ra một mô hình cho xem tài liệu và lắng nghe để thay đổi đó?
Kỹ thuật xuất sắc. Cảm ơn! –