How to use the backbone.Model 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 Uninett / nav / python / nav / web / static / js / src / ipam / views / subnetallocator.js View on Github external
initialize: function(opts) {
      this.parent_fsm = opts.fsm;
      this.node = opts.node;
      this.model = new Backbone.Model(this.node);
      this.model.set("creation_url", null);
      // Since template uses states, rerender on new state
      this.fsm.onChange(this.render);
      this.fsm.onChange(function (state) {
        console.log("RESERVATION went into state", state);
      });
    },
github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / components / form-components / editors / fill / input-color / input-categories / input-color-categories.js View on Github external
initialize: function (opts) {
    checkAndBuildOpts(opts, REQUIRED_OPTS, this);
    this._imageEnabled = opts.imageEnabled;
    this._hideTabs = opts.hideTabs;
    this.listenTo(this.model, 'change:attribute', this._fetchColumns);
    this._viewModel = new Backbone.Model({
      step: 0,
      status: 'idle'
    });

    this.listenTo(this._viewModel, 'change:status', this.render);

    // If it comes from a quantification change
    if (this.model.hasChanged('quantification') && this.model.get('quantification') === 'category') {
      this._fetchColumns();
    }
  },
github CartoDB / carto.js / test / spec / analysis / analysis-factory.spec.js View on Github external
var map = {
          'trade-area': ['source'],
          'estimated-population': ['source'],
          'sql-function': ['source', 'target']
        };
        return map[analysisType];
      },
      getParamNamesForAnalysisType: function (analysisType) {
        var map = {
          'trade-area': ['kind', 'time'],
          'estimated-population': ['columnName']
        };
        return map[analysisType];
      }
    };
    this.vis = new Backbone.Model();
    this.analysisCollection = new Backbone.Collection();
    this.analysisFactory = new AnalysisFactory({
      camshaftReference: this.fakeCamshaftReference,
      analysisCollection: this.analysisCollection,
      vis: this.vis
    });
  });
github CartoDB / carto.js / test / spec / geo / ui / tooltip.spec.js View on Github external
beforeEach(function () {
    this.container = $("<div id="map">").css('height', '1000px');
    $('body').append(this.container);
    var map = new Map(null, { layersFactory: {} });
    this.mapView = new LeafletMapView({
      el: $('#map'),
      mapModel: map,
      engine: new Backbone.Model(),
      layerViewFactory: jasmine.createSpyObj('layerViewFactory', ['createLayerView']),
      layerGroupModel: new Backbone.Model()
    });
    this.mapView.render();

    this.layerView = new Backbone.View();
    this.tooltipModel = new TooltipModel({
      template: '{{#fields}}{{{ value }}},{{/fields}}'
    });
    this.tooltipView = new TooltipView({
      model: this.tooltipModel,
      layerView: this.layerView,
      mapView: this.mapView
    });
  });
</div>
github CartoDB / carto.js / test / spec / geo / ui / tooltip.spec.js View on Github external
beforeEach(function () {
    this.container = $("<div id="map">").css('height', '1000px');
    $('body').append(this.container);
    var map = new Map(null, { layersFactory: {} });
    this.mapView = new LeafletMapView({
      el: $('#map'),
      mapModel: map,
      engine: new Backbone.Model(),
      layerViewFactory: jasmine.createSpyObj('layerViewFactory', ['createLayerView']),
      layerGroupModel: new Backbone.Model()
    });
    this.mapView.render();

    this.layerView = new Backbone.View();
    this.tooltipModel = new TooltipModel({
      template: '{{#fields}}{{{ value }}},{{/fields}}'
    });
    this.tooltipView = new TooltipView({
      model: this.tooltipModel,
      layerView: this.layerView,
      mapView: this.mapView
    });
  });
</div>
github apache / ranger / security-admin / src / main / webapp / scripts / views / service / ServiceForm.js View on Github external
_.each(this.model.get('configs'),function(value, name){
					var configObj = _.findWhere(this.rangerServiceDefModel.get('configs'),{'name' : name });
					if(!_.isUndefined(configObj) && configObj.type == 'bool'){
						this.model.set(name, this.getStringFromBoolean(configObj, value))
					} else {
						this.model.set(name, value)
						if(_.isUndefined(configObj)){
							this.extraConfigColl.add(new Backbone.Model({'name' : name, 'value' : value}))
						}
					}
				},this);
			}
github CartoDB / cartodb / lib / assets / javascripts / builder / editor / layers / layer-content-views / data / data-view.js View on Github external
_initModels: function () {
    this._infoboxModel = new InfoboxModel({
      state: this._isLayerHidden()
        ? 'layer-hidden'
        : ''
    });

    this._layerDefinitionModel.canBeGeoreferenced()
      .then(function (canBeGeoreferenced) {
        if (!this._isLayerHidden() && canBeGeoreferenced) {
          this._infoboxModel.set('state', 'georeference');
        }
      }.bind(this));

    this._overlayModel = new Backbone.Model({
      visible: this._isLayerHidden()
    });

    this._applyButtonStatusModel = new Backbone.Model({
      loading: false
    });

    this._togglerModel = new Backbone.Model({
      labels: [_t('editor.data.data-toggle.values'), _t('editor.data.data-toggle.cartocss')],
      active: this._editorModel.isEditing(),
      disabled: this._editorModel.isDisabled(),
      tooltip: _t('editor.data.data-toggle.tooltip')
    });
  },
github alphagov / spotlight / spec / server-pure / views / spec.services.js View on Github external
beforeEach(function () {
    model = new Backbone.Model({
      axesOptions: servicesController.serviceAxes.axes
    });

    collection = new ServicesCollection([{
      title: 'Prescriptions: prepayment certificates issued',
      department: {
        title: 'Department of Health',
        abbr: 'DH'
      },
      agency: {
        title: 'NHS Business Services Authority',
        abbr: 'NHSBSA'
      },
      completion_rate: 0.4,
      number_of_transactions: 2000,
      digital_takeup: 0
github CartoDB / cartodb / lib / assets / javascripts / cartodb3 / components / dataset / dataset-base-view.js View on Github external
initialize: function (opts) {
    checkAndBuildOpts(opts, REQUIRED_OPTS, this);

    this._clearSQLModel = new Backbone.Model({
      visible: false
    });

    this._sqlModel = this._layerDefinitionModel.sqlModel;

    this._SQL = new cdb.SQL({
      user: this._configModel.get('user_name'),
      sql_api_template: this._configModel.get('sql_api_template'),
      api_key: this._configModel.get('api_key')
    });

    this._codemirrorModel = new Backbone.Model({
      content: this._querySchemaModel.get('query'),
      readonly: false
    });

    SQLNotifications.track(this);
  },
github CartoDB / cartodb / deep-insights / spec / dashboard-below-map-view.spec.js View on Github external
var createFakeDataviewLayer = function (attrs) {
  return new Backbone.Model(attrs);
};