akre54 / Backbone.NativeView

A reference implementation of a native Backbone.View
MIT License
113 stars 18 forks source link

this._domEvents isn't initialized properly when mixing into Backbone.View #15

Closed osi closed 9 years ago

osi commented 9 years ago

When initializing the mixin via against the Backbone 1.2.0 release,

_.extend(Backbone.View.prototype, Backbone.NativeViewMixin);

this._domEvents is never initialized

akre54 commented 9 years ago

From the docs:

var MyBaseView = Backbone.View.extend({
  initialize: function(options) {
    // If you go the prototype extension route be sure to set _domEvents in
    // initialize yourself.
    this._domEvents = [];
  }
});

_.extend(MyBaseView.prototype, Backbone.NativeViewMixin);

You can also extend from Backbone.NativeView.

osi commented 9 years ago

my bad. i had first tried the D3 view version, but then switched to this when I realized it wanted to create SVG elements by default. The mixin instructions were slightly different between the two. Thanks!

akre54 commented 9 years ago

Yup, d3 does its own event binding under the hood, we have to roll our own here. You can use them both in tandem if you only need d3 some places