src/collection.js
function(item) {
      var self = this;
      var items = Array.isArray(item) ? item : [item];
      var added = false;
      _.each(items, function(item) {
        if(!_.contains(self.items, item)) {
          self.items.push(item);
          if(item && item.klass == 'Instance') {
            item.once('delete', function() {
              self.remove(item);
            });
          };
          added = true;
        }
      });
      if(added) {
        self.emit('add');
        self.emit('change:size');
        self.emit('change');
      }
      return self;
    }
function(item) {
      var self = this;
      var items = Array.isArray(item) ? item : [item];
      var added = false;
      _.each(items, function(item) {
        if(!_.contains(self.items, item)) {
          self.items.push(item);
          if(item && item.klass == 'Instance') {
            item.once('delete', function() {
              self.remove(item);
            });
          };
          added = true;
        }
      });
      if(added) {
        self.emit('add');
        self.emit('change:size');
        self.emit('change');
      }
      return self;
    }
function ( item ) { var self = this ; var items = Array . isArray ( item ) ? item : [ item ] ; var added = false ; _ . each ( items , function ( item ) { if ( ! _ . contains ( self . items , item ) ) { self . items . push ( item ) ; if ( item && item . klass == 'Instance' ) { item . once ( 'delete' , function ( ) { self . remove ( item ) ; } ) ; } ; added = true ; } } ) ; if ( added ) { self . emit ( 'add' ) ; self . emit ( 'change:size' ) ; self . emit ( 'change' ) ; } return self ; }
Add one or many items
Add one or many items