// must update backbone-couch connector to support these settings then delete per collection changes setting.
//Backbone.couch_connector.config.single_feed = true;
var WifiLink = Backbone.Model.extend({
var WifiLinksCollection = Backbone.Collection.extend({
var LinkLineView = Backbone.View.extend({
var WifiLinksView = Backbone.View.extend({
initialize: function(collection){
var Network = Backbone.Model.extend({
var NetworksCollection = Backbone.Collection.extend({
// Collection of all attributes and as such keeper of most of the data.
// Other collections not contained here try to merely keep references (id's)
// the these attributes/facets/properties.
var Attributes = Backbone.Collection.extend({
// Contain most data defining the Attribute/Property/Facet(/Filter)
// Grouping and Filter placement is maintained in separate collections
var Attribute = Backbone.Model.extend({
initialize: function () {
// Value collection held by an attribute
var Values = Backbone.Collection.extend({
initialize: function (data,options) {
// A single value of a facet
var Value = Backbone.Model.extend({
# Backbone Extensions
Backbone is flexible, simple, and powerful. However, you may find that the complexity of the application you are working on requires more than what it provides out of the box. There are certain concerns which it just doesn't address directly as one of its goals is to be minimalist.
Take for example Views, which provide a default `render` method which does nothing and produces no real results when called, despite most implementations using it to generate the HTML that the view manages. Also, Models and Collections have no built-in way of handling nested hierarchies - if you require this functionality, you need to write it yourself or use a plugin.
In these cases, there are many existing Backbone plugins which can provide advanced solutions for large-scale Backbone apps. A fairly complete list of plugins and frameworks available can be found on the Backbone [wiki](https://github.com/documentcloud/backbone/wiki/Extensions%2C-Plugins%2C-Resources). Using these add-ons, there is enough for applications of most sizes to be completed successfully.
[MarionetteJS](http://marionettejs.com) (a.k.a. Backbone.Marionette) provides many of the features that the non-trivial application developer needs, above what Backbone itself provides. It is a composite application library that aims to simplify the construction of large scale applications. It does this by providing a collection of common design and implementation patterns found in the applications that the creator, [Derick Bailey](http://lostechies.com/derickbailey/), and many other [contributors](https://github.com/marionettejs/backbone.marionette/graphs/contributors) have been using to build Backbone apps.
Marionette's components range greatly in the features they provide, but they all work together to create a composite application layer that can both reduce boilerplate code and provide a much needed application structure. Its core components include various and specialized view types that take the boilerplate out of rendering common Backbone.Model and Backbone.Collection scenarios; an Application object and Module architecture to scale applications across sub-applications, features and files; integration of a command pattern, event aggregator, and request/response mechanism; and many more object types that can be extended in a myriad of ways to create an architecture that facilitates an application's specific needs.
```javascript
var MyView = Backbone.View.extend({
wss.model.Week = Backbone.Model.extend({
wss.model.LoggedUser = Backbone.Model.extend({
wss.model.WorkShift = Backbone.Model.extend({
wss.model.ShiftList = Backbone.Collection.extend({
wss.model.PlannedShift = Backbone.Model.extend({
wss.model.PlannedShiftList = Backbone.Collection.extend({
wss.model.User = Backbone.Model.extend({
wss.model.UserList = Backbone.Collection.extend({
// Backbone Models and Collections to be used both client/server side.
// Note that these models are read-only - no `PUT/POST/DELETE` expected.
Settings = require('settings'),
Backbone = require('backbone.js'),
// file basename, e.g. `foo.mbtiles` has an `id` of `foo`.
var Tileset = Backbone.Model.extend({
initialize: function(attributes) {
Backbone.Model.prototype.initialize.call(this, attributes);
parse: function(response){
var model = Backbone.Model.prototype.parse.call(this, response);
// -------
// Collection of all tileset models.
var TilesetList = Backbone.Collection.extend({
model: Tileset,
// backbone examples:
// http://documentcloud.github.com/backbone/docs/todos.html
// http://documentcloud.github.com/backbone/examples/todos/index.html
// http://coenraets.org/blog/2011/12/backbone-js-wine-cellar-tutorial-part-1-getting-started/
// http://www.quora.com/What-are-some-good-resources-for-Backbone-js
var Task = Backbone.Model.extend({
var TaskList = Backbone.Collection.extend({
var TaskView = Backbone.View.extend({
var AppView = Backbone.View.extend({
// Backbone structure
var SFDemoApp = {}
SFDemoApp.DataCollection = Backbone.Collection.extend({});
SFDemoApp.ListItemView = Backbone.View.extend({
tagName: 'li',
SFDemoApp.ListView = Backbone.View.extend({
this.collection.each(function(list) {
console.log('success',res);
var list = new SFDemoApp.ListView({collection:new SFDemoApp.DataCollection(res.records),el:$("#record_list")});
Backbone.View.prototype.close = function(){
this.remove();
var Report = Backbone.Model.extend({
var ReportCollection = Backbone.Collection.extend(
*/
var ReportListView = Backbone.View.extend(
removeReport : function() {
// If we have an empty collection, show 'no reports' message
var ReportListLiView = Backbone.View.extend({
filters = _.extend({ c:[], m:[], mode:[] }, filters);
_.each(data.payload.incidents, function (item, i) { data.payload.incidents[i].id = item.incident.incidentid; });
// Set up collection
# Backbone localStorage Adapter v1.1.5
[](http://travis-ci.org/jeromegn/Backbone.localStorage)
Quite simply a localStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database.
Include Backbone.localStorage after having included Backbone.js:
```javascript
window.SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection"), // Unique name within your app.
define("someCollection", ["localstorage"], function() {
var SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection") // Unique name within your app.
});
/*
Backbone.js implementation of history panel
events (local/ui and otherwise)
HistoryCollection: (collection of History: 'Saved Histories')
convert function comments to jsDoc style, complete comments
collection -> show_deleted, show_hidden
//==============================================================================
var HistoryItemView = BaseView.extend( LoggableMixin ).extend({
//==============================================================================
var HistoryCollection = Backbone.Collection.extend({
//------------------------------------------------------------------------------
var HistoryView = BaseView.extend( LoggableMixin ).extend({
// view for the HistoryCollection (as per current right hand panel)
};
_.extend( mockHistory.data, {
/*
Backbone.js implementation of history panel
events (local/ui and otherwise)
HistoryCollection: (collection of History: 'Saved Histories')
convert function comments to jsDoc style, complete comments
collection -> show_deleted, show_hidden
//==============================================================================
var HistoryItemView = BaseView.extend( LoggableMixin ).extend({
//==============================================================================
var HistoryCollection = Backbone.Collection.extend({
//------------------------------------------------------------------------------
var HistoryView = BaseView.extend( LoggableMixin ).extend({
// view for the HistoryCollection (as per current right hand panel)
};
_.extend( mockHistory.data, {
/*
Backbone.js implementation of history panel
events (local/ui and otherwise)
HistoryCollection: (collection of History: 'Saved Histories')
convert function comments to jsDoc style, complete comments
collection -> show_deleted, show_hidden
//==============================================================================
var HistoryItemView = BaseView.extend( LoggableMixin ).extend({
//==============================================================================
var HistoryCollection = Backbone.Collection.extend({
//------------------------------------------------------------------------------
var HistoryView = BaseView.extend( LoggableMixin ).extend({
// view for the HistoryCollection (as per current right hand panel)
};
_.extend( mockHistory.data, {
Backbone.associate
==================
Presumptionless model relations for Backbone in < 1kb.
[](https://travis-ci.org/rjz/backbone-associate)
Use `Backbone.associate` to define relationships between application models
and collections.
var Flag = Backbone.Model.Extend({ /* ... */ }),
City = Backbone.Model.Extend({ /* ... */ }),
Cities = Backbone.Collection.extend({ model: City }),
Country = Backbone.Model.Extend({ /* ... */ });
# Backbone localStorage Adapter v1.1.7
[](http://travis-ci.org/jeromegn/Backbone.localStorage)
Quite simply a localStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database.
Include Backbone.localStorage after having included Backbone.js:
```javascript
window.SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection"), // Unique name within your app.
define("SomeCollection", ["localstorage"], function() {
var SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection") // Unique name within your app.
});
# Backbone.Safe - local storage plugin
Backbone.Safe is a plugin for Backbone.js which stores a model's or a collection's json data to the local storage on set operations, regardless server side existance.
The concept for Backbone.Safe has been created while the developing the [Echoes Player project](https://github.com/orizens/echoes).
## Install
```
bower install backbone.safe
## Usage
The latest update to Backbone.Safe allows one to define safe with a non distructive definition using a key as such:
```javascript
var UserProfile = Backbone.Model.extend({
```
With this method, when Safe is not present, the model/collection still functions as expected.
```javascript
var HistoryPlaylist = Backbone.Collection.extend({
initialize: function() {
Backbone.Safe.create('historyPlaylist', this);
// Collection of messages that belong to a frame
var Stream = Backbone.Collection.extend({
model: Message,
// All channels/private message chats a user has open
var WindowList = Backbone.Collection.extend({
var UserList = Backbone.Collection.extend({
this.channel = channel;
this.view = new UserListView({collection:this});
#Backbone and Angular
- [Angular Videos](https://egghead.io/)
- [Backbone Tutorial](http://adrianmejia.com/blog/2012/09/11/backbone-dot-js-for-absolute-beginners-getting-started)
### Backbone
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ajax Tabs Using Backbone</title>
var TabModel = Backbone.Model.extend({
var TabsCollection = Backbone.Collection.extend({
var TabView = Backbone.View.extend({
var AppView = Backbone.View.extend({
/*
Collection model. Note that we've set the url property. We're using the
built in Backbone.sync logic, so items in this collection will pass their
ids as the last segment (e.g. /api/recipe/12). Note how Backbone provides
a *ton* of functionality, while this is minimal code!
define( [
'backbone',
'models/recipe-model'
], function ( Backbone, $, RecipeModel ) {
return Backbone.Collection.extend( {
url: "/api/recipe",
//***************************************************************************//
//******************* Collection ***********************//
var MyCollection = Backbone.Collection.extend({
var Events = MyCollection.extend({
var Artists = MyCollection.extend({
var Musicians = MyCollection.extend({
model:Musician
// parse: function (attrs, opt) { chabloz parse dans l'extension de backbone
var Instruments = MyCollection.extend({
var Representers = MyCollection.extend({
//
// Collection for GitHub "commits".
// [Sharify](https://github.com/artsy/sharify) lets us require the API url
// and Backbone.sync is replaced with a server-side HTTP module in /lib/setup
// using [Backbone Super Sync](https://github.com/artsy/backbone-super-sync).
// This combined with [browerify](https://github.com/substack/node-browserify)
var Backbone = require('backbone'),
module.exports = Commits = Backbone.Collection.extend({