Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone.js: access parent view from child view?

In general, how to access parent view from a child view in Backbone?

Specifically, in Backgrid.js, is there a way to access parent row from a cell?

like image 877
eugene Avatar asked Oct 16 '13 08:10

eugene


1 Answers

Pass this as an option to the child view on initialization step:

var ChildView = Backbone.View.extend({
  initialize : function (options) {
    this.parent = options.parent;
  }
});

// somewhere in the parent view ...
new ChildView({parent:this});
like image 131
Vitalii Petrychuk Avatar answered Oct 23 '22 22:10

Vitalii Petrychuk