Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukasolson/backbone-super
A convenient super method for the popular JavaScript library, Backbone.js.
https://github.com/lukasolson/backbone-super
Last synced: about 1 month ago
JSON representation
A convenient super method for the popular JavaScript library, Backbone.js.
- Host: GitHub
- URL: https://github.com/lukasolson/backbone-super
- Owner: lukasolson
- License: mit
- Created: 2012-06-27T21:08:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-01-17T20:03:46.000Z (over 8 years ago)
- Last Synced: 2024-05-10T22:09:16.915Z (about 1 month ago)
- Language: JavaScript
- Size: 426 KB
- Stars: 208
- Watchers: 12
- Forks: 24
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - backbone-super
README
[![Build Status](https://travis-ci.org/lukasolson/backbone-super.svg)](https://travis-ci.org/lukasolson/backbone-super)
# Backbone-Super
This Backbone.js plugin provides a convenient super method.
Usually, when you're using Backbone.js, you have to do some funky (well, not funky... Javascript-y) stuff to be able to access parent methods.
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);
...
}
});
```After including this plugin, you can do the same thing with the following syntax:
```javascript
var Note = Backbone.Model.extend({
set: function(attributes, options) {
this._super(attributes, options);
...
}
});
```To use it, simply include it after you include Backbone.js:
```javascript
```
To use it with Browserify:
```javascript
var Backbone = require('backbone'),
Note;Backbone.$ = require('jquery');
Backbone._ = require('underscore');
require('backbone-super');Note = Backbone.Model.extend({
set: function(attributes, options) {
this._super(attributes, options);
...
}
});module.exports = Note;
```License: MIT