Home Manual ReferenceGraphs Source Repository

Function

Static Public Summary
public

extend(protoProps: object, staticProps: object): *

Provides older "extend" functionality for Backbone.

public

sync(method: string, model: Model | Collection, options: object): XMLHttpRequest

Backbone.sync - Persists models to the server.

Static Public

public extend(protoProps: object, staticProps: object): * source

import extend from 'backbone-es6/src/extend.js'

Provides older "extend" functionality for Backbone. While it is still accessible it is recommended to adopt the new Backbone-ES6 patterns and ES6 sub-classing via "extends".

Helper function to correctly set up the prototype chain for subclasses. Similar to goog.inherits, but uses a hash of prototype properties and class properties to be extended.

Params:

NameTypeAttributeDescription
protoProps object

instance properties

staticProps object

class properties

Return:

*

Subclass of parent class.

See:

public sync(method: string, model: Model | Collection, options: object): XMLHttpRequest source

import sync from 'backbone-es6/src/sync.js'

Backbone.sync - Persists models to the server. (http://backbonejs.org/#Sync)

Override this function to change the manner in which Backbone persists models to the server. You will be passed the type of request, and the model in question. By default, makes a RESTful Ajax request to the model's url(). Some possible customizations could be:

Use setTimeout to batch rapid-fire updates into a single request. Send up the models as XML instead of JSON. Persist models via WebSockets instead of Ajax.

Turn on Backbone.emulateHTTP in order to send PUT and DELETE requests as POST, with a _method parameter containing the true HTTP method, as well as all requests with the body as application/x-www-form-urlencoded instead of application/json with the model in a param named model. Useful when interfacing with server-side languages like PHP that make it difficult to read the body of PUT requests.

Params:

NameTypeAttributeDescription
method string

A string that defines the synchronization action to perform.

model Model | Collection

The model or collection instance to synchronize.

options object

Optional parameters

Return:

XMLHttpRequest

An XMLHttpRequest