Skip to content

A few nice snippets around backbone that are not big enough to deserve their own plugin

License

Notifications You must be signed in to change notification settings

asciidisco/Backbone.Utils

Repository files navigation

Backbone.Utils

A few nice snippets around backbone that are not big enough to deserve their own plugin

Build Status

Installation

The plugin itself implements the Universal Module Definition (UMD). You can use it with a CommonJS like loader, or with an AMD loader or via vanilla javascript.

The plugin has two dependencies, underscore.js and backbone.js

Dowload

You can directly download the Development Version or the Production Version from the root folder

VOLO

$ volo add Backbone.Utils

BOWER

$ bower install backbone.utils

JAM

$ jam install Backbone.Utils

NPM

$ npm install Backbone.Utils

Integration

AMD

// AMD
require(['underscore', 'backbone', 'path/to/backbone.utils'], function (_, Backbone, Utils) {
  /* Do stuff with Backbone here */
});

CommonJS

// CommonJS
var _ = require('underscore');
var Backbone = require('backbone');
var Utils = require('backbone.utils');

Vanilla JS

<!-- Vanilla javascript -->
<script src="path/to/underscore.js"></script>
<script src="path/to/backbone.js"></script>
<script src="path/to/backbone.utils.js"></script>
<script>
	console.log(Backbone.Utils); // Backbone and the Utils property are globals
</script>

Methods

Soft Extend Enables you to extend ressources like object literals, so you can do now smth. like this:

var Parent = Backbone.Model.extend({
	params: {
		foo: 'bar',
		bar: 'foo'
	}
});

var Child = Parent.softExtend(['params'], {
	params: {
		bar: 'I´ve got softly extended',
		baz: 'I´am new!'
	}
});

// State of params in 'Child'
var child = new Child();
console.log(child.params);

// {
//	foo: 'bar',
//	bar: 'I´ve got softly extended',
//	baz: 'I´am new!'
// }

About

A few nice snippets around backbone that are not big enough to deserve their own plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published