How to use the backbone.Collection function in backbone

To help you get started, we’ve selected a few backbone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cyverse / troposphere / troposphere / static / js / components / modals / instance / image / steps / VisibilityStep.jsx View on Github external
onVisibilityChange: function(newVisibility) {
        // reset visibility will also reset the lists to empty
        this.setState({
            visibility: newVisibility,
            imageUsers: new Backbone.Collection(),
            activeAccessList: new Backbone.Collection()
        });
    },
github libremap / libremap-webui / src / js / models / libreMap.js View on Github external
initialize: function(options) {
    this.layer_plugins = options.layer_plugins || {};

    this.set('baseLayers', new Backbone.Collection());
    this.set('overlays', new Backbone.Collection());

    var process_layercfg = function(coll, layercfg) {
      var layer_plugin = this.layer_plugins[layercfg.type];
      if (!layer_plugin) {
        return;
      }
      coll.add(new layer_plugin.model(layercfg));
    };
      
    // read defaults from appconfig
    _.each(appconfig.baseLayers, _.bind(process_layercfg, this, this.get('baseLayers')));
    _.each(appconfig.overlays, _.bind(process_layercfg, this, this.get('overlays')));
  }
});
github CartoDB / cartodb / lib / assets / javascripts / cartodb / new_dashboard / categories_view.js View on Github external
initialize: function() {
    this.router = this.options.router;
    this.localStorage = this.options.localStorage;
    // TODO: Get categories using an API.
    this.collection = new Backbone.Collection(); 
    this.template = cdb.templates.getTemplate('new_dashboard/views/categories');

    this._initBinds();
  },
github CartoDB / carto.js / test / spec / dataviews / dataviews-collection.spec.js View on Github external
it('should remove item when removed', function () {
    var map = jasmine.createSpyObj('map', ['getViewBounds', 'off']);
    map.getViewBounds.and.returnValue([[0, 0], [0, 0]]);
    var vis = jasmine.createSpyObj('vis', ['reload']);
    var layer = new Backbone.Model();
    var dataviewModel = new DataviewModel({source: {id: 'a0'}}, {
      map: map,
      vis: vis,
      analysisCollection: new Backbone.Collection(),
      layer: layer
    });
    this.collection.add(dataviewModel);
    expect(this.collection.length).toEqual(1);
    this.collection.first().remove();
    expect(this.collection.length).toEqual(0);
  });
});
github gregberge / bobun / test / view.js View on Github external
beforeEach(function () {
      bobunView.collection = new Backbone.Collection([{foo: 'bar'}]);
      bobunView.model = new Backbone.Model({foo: 'bar'});
    });
github comindware / core-ui / src / form / editors / DatalistEditorView.ts View on Github external
__createSelectedCollections() {
        const selectedCollection = (this.selectedCollection = new Backbone.Collection());
        this.selectedCollection.model = Backbone.Model.extend({
            initialize() {
                this.selectableCollection = selectedCollection;
                _.extend(this, new SelectableBehavior.Selectable(this));
            }
        });

        _.extend(this.selectedCollection, new SelectableBehavior.SingleSelect(this.selectedCollection));

        if (this.isButtonLimitMode) {
            this.selectedButtonCollection = new Backbone.Collection();
            this.selectedPanelCollection = new Backbone.Collection();
        }
    },
github jamiebuilds / marionette-wires / api / colors / routes.js View on Github external
var Backbone = require('backbone');
var fixture = require('./fixture');
var collection = new Backbone.Collection(fixture);

var id = collection.length;

module.exports = function(api) {
  api.route('/api/colors')
    .get(function(req, res) {
      res.json(collection);
    })
    .post(function(req, res) {
      var model = new Backbone.Model(req.body);
      model.set('id', ++id);
      collection.add(model);
      res.json(model);
    });

  api.route('/api/colors/:id')
github cyverse / troposphere / troposphere / static / js / components / modals / instance / image / steps / BootScriptsLicensingStep.jsx View on Github external
getDefaultProps: function() {
        return {
            licenses: new Backbone.Collection(),
            activeLicenses: new Backbone.Collection(),
            scripts: new Backbone.Collection(),
            activeScripts: new Backbone.Collection()
        };
    },
github DDMAL / cantus / public / cantusdata / frontend / public / js / app / layout / RootView.js View on Github external
onRender: function ()
    {
        const navLinks = new Backbone.Collection(null, {sorted: false});

        this.menuSidenav.show(new MenuSidenavView({collection: navLinks}));
        this.header.show(new HeaderView({collection: navLinks}));
    }
});
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / component / query-settings / query-settings.view.js View on Github external
setupSortFieldDropdown() {
      this.settingsSortField.show(
        new SortItemCollectionView({
          collection: new Backbone.Collection(this.model.get('sorts')),
          showBestTextOption: true,
        })
      )
    },
    setupSrcDropdown() {