backbone.picky icon indicating copy to clipboard operation
backbone.picky copied to clipboard

`applyTo` class method for setting up mixins

Open hashchange opened this issue 11 years ago • 0 comments

With this (minor) change, Picky mixins can be applied with a single statement:

SelectableModel = Backbone.Model.extend({
  initialize: function(){
    Backbone.Picky.Selectable.applyTo(this);
  }
});

SingleSelect and MultiSelect mixins work along the same lines. It is a little simpler and more readable than the previous procedure.

Also, I have removed support for creating Picky objects solely with the constructor, like this:

var singleSelect = new Backbone.Picky.SingleSelect(myCollection);

It didn't work any more (don't know exactly when it broke). It would have been tedious to fix reliably, and seemed - to me at least - to to against the grain of how Backbone entities are usually created (based on types, with extend). My "fix" was to remove it from the documentation - no change in code.

hashchange avatar Jan 27 '14 09:01 hashchange