akre54 / Backbone.NativeView

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

#setElement should handle array-likes #20

Closed jridgewell closed 9 years ago

jridgewell commented 9 years ago

This allows views to directly pass this.$('selector') to a subview's constructor or directly to #setElement:

var View = Backbone.View.extend({
  render: function() {
    // Do something...
    // Attach a subview to this view's element
    var subView = new SubView({
      el: this.$('.selector')
    });

    // Or...
    subview.setElement(this.$('.selector'));
  }
});
akre54 commented 9 years ago

Awesome. Thanks.