backbone, 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?

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});

// You can use this code instead

var ChildView = Backbone.View.extend({
  initialize : function (options) {
    this._configure(options); // Set all the options as local variables
    // This is used in the Backbone.View code on the latest version

  }
});

Need Your Help

How to solve slow Java `SecureRandom`?

java performance security random entropy

If you want a cryptographically strong random number in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses /dev/random on Linux, it can block waiting for sufficient

What is @permalink and get_absolute_url in Django?

django

What is @permalink and get_absolute_url in Django? When and why to use it?