I am new to Backbone and I would like to know how to do it. I would like for an easy way to contact the parent view from the child, that is, call the method on the parent.
The following is an example of an example using the desktop and document views:
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() {
Should I create a model to represent the document and listen to the changes in this?
user888734
source share