How to use the Model function from backbone
Find comprehensive JavaScript backbone.Model code examples handpicked from public code repositorys.
4 5 6 7 8 9 10 11 12 13
var MediaController = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model({ currentShortcode: null, action: 'select', search: null, insertCallback: this.insertCallback,
149
670
60
GitHub: jamovi/jamovi
34 35 36 37 38 39 40 41 42 43
readonly index?: number; readonly onlyOne?: boolean; } const Instance = Backbone.Model.extend({ initialize() { this.transId = 0;
52
458
25
+ 3 other calls in file
GitHub: jamovi/jamovi
14 15 16 17 18 19 20 21 22 23
const AnalyseTab = require('./ribbon/analysetab'); const Notifs = require('./ribbon/notifs'); const focusLoop = require('../common/focusloop'); const selectionLoop = require('../common/selectionloop'); const RibbonModel = Backbone.Model.extend({ initialize(args) { this._modules = args.modules; this._settings = args.settings;
52
457
25
GitHub: voxmedia/autotune
4 5 6 7 8 9 10 11 12 13
_ = require('underscore'), moment = require('moment'), utils = require('../utils'), markdown = require('markdown').markdown; var Project = Backbone.Model.extend({ urlRoot: '/projects', /** * Constructor. Looks for `blueprint` or `blueprint_name` in the object passed in.
37
414
145
+ 5 other calls in file
GitHub: voxmedia/autotune
2 3 4 5 6 7 8 9 10 11
var Backbone = require('backbone'), _ = require('underscore'), utils = require('../utils'), ProjectCollection = require('./project_collection'); var Blueprint = Backbone.Model.extend({ /** * Constructor. * @param {object} args Arguments passed to the constructor **/
37
414
145
GitHub: voxmedia/autotune
0 1 2 3 4 5 6 7 8 9
"use strict"; var Backbone = require('backbone'), _ = require('underscore'); var Theme = Backbone.Model.extend({ /** * Get the AJAX endpoint for this blueprint. * @returns {string} **/
37
414
145
8 9 10 11 12 13 14 15 16 17
From the Backbone.js documentation: > Brief aside on super: JavaScript does not provide a simple way to call super — the function of the same name defined higher on the prototype chain. If you override a core function like set, or save, and you want to invoke the parent object's implementation, you'll have to explicitly call it, along these lines: > ```javascript var Note = Backbone.Model.extend({ set: function(attributes, options) { Backbone.Model.prototype.set.call(this, attributes, options); ... }
24
209
11
+ 7 other calls in file
32 33 34 35 36 37 38 39 40 41
var BaseView = function(options) { this.viewId = makeId(options); this.refs = {}; var Props = this.propsModel || Backbone.Model; this.props = new Props( _.omit(options, Config.ViewOptions) ); this._bindChannels(); Backbone.View.apply(this, arguments);
31
202
46
GitHub: mulesoft/api-notebook
3 4 5 6 7 8 9 10 11 12
/** * Model used for holding a notebooks meta data. * * @type {Function} */ var Meta = module.exports = Backbone.Model.extend(); /** * Reset a model by removing any unused attributes and updating everything else. *
45
152
0
+ 3 other calls in file
GitHub: mulesoft/api-notebook
73 74 75 76 77 78 79 80 81 82
storage[method](this._persistenceKey(attr), attrs[attr]); } } } return Backbone.Model.prototype.set.apply(this, arguments); }; /** * Override `clear` to also empty localStorage.
45
152
472
+ 7 other calls in file
220 221 222 223 224 225 226 227 228 229
return Marionette.ItemView.extend({ initialize: function(options) { var attrs = extractAttributes(options); this.model = new Backbone.Model(attrs); }; }); // bad (extractAttributes is an additional method on the view unnecessarily)
42
156
52
15 16 17 18 19 20 21 22 23 24
expect(this.policy.shouldEvictItem({ evictMe: true })).to.be.false; }); describe("backbone configuration", function () { beforeEach(function () { this.Model = Backbone.Model.extend({url: 'url'}); this.model = new this.Model({ id: 1, value: 1 }); this.collection = new Backbone.Collection(); this.collection.add(this.model); });
10
58
59
+ 3 other calls in file
GitHub: blitzagency/rich
173 174 175 176 177 178 179 180 181 182
if(this.properties.size){ w = this.properties.size[0] || 0; h = this.properties.size[1] || 0; } this._constraintRelations = new backbone.Model({}); this._autolayout.width = autolayout.cv('width', w); this._autolayout.height = autolayout.cv('height', h); this._autolayout.top = autolayout.cv('top', 0); this._autolayout.right = autolayout.cv('right', 0);
6
35
14
GitHub: dclegalhackers/prose
9 10 11 12 13 14 15 16 17 18
var auth = require('../config'); var cookie = require('../cookie'); var templates = require('../../dist/templates'); module.exports = Backbone.Model.extend({ initialize: function(attributes, options) { this.repos = new Repos([], { user: this }); this.orgs = new Orgs([], { user: this }); },
744
0
12
19 20 21 22 23 24 25 26 27 28
*/ const CURRENT_VERSION = 1; const KeeVaultEmbeddedConfigModel = Backbone.Model.extend({ defaults: function() { return { version: CURRENT_VERSION,
7
57
7
67 68 69 70 71 72 73 74 75 76 77 78 79
Automation.EventAggregator = function () { var EA = function(){}; // Copy the *extend* function used by Backbone's classes EA.extend = Backbone.Model.extend; // Copy the basic Backbone.Events on to the event aggregator _.extend(EA.prototype, Backbone.Events);
23
17
4
GitHub: wotcity/ui-moving-line
32 33 34 35 36 37 38 39 40 41 42 43
/** * MODELS **/ app.Container = Backbone.Model.extend({ url: function() { return '/'; }, wsUrl: function() {
7
1
3
GitHub: sofiafaddi/REACTJS
31 32 33 34 35 36 37 38 39 40 41
}, idAttribute: 'id', url: '/test' }); const userModel = Backbone.Model.extend({ defaults: { name: '' }, idAttribute: 'name',
0
0
0
GitHub: Demdis/polis
131 132 133 134 135 136 137 138 139 140
this.gotoRoute("/user/create", { trigger: true }); // RootView.getInstance().setView(new LandingPageView()); // RootView.getInstance().setView(new CreateUserFormView({ // model : new Backbone.Model({ // // zinvite: zinvite, // create: true // }) // }));
0
0
1
+ 2 other calls in file
backbone.View is the most popular function in backbone (151 examples)