Class: Element

Element

new Element()

The base element class

Source:

Members

config :Object

The config object for the element

Type:
  • Object
Source:

factory :Factory

The Factory that created the element

Type:
Source:

fromServer :Boolean

Whether the element is from the server or not

Type:
  • Boolean
Source:

route :String

The route

Type:
  • String
Source:

Methods

get(routeOrParams) → {Promise.<Element>}

Make a GET request

Parameters:
Name Type Description
routeOrParams string | object

If it's a string, it's the route for the request, otherwise it's the params for the request

Source:
Returns:

A Promise that is resolved with an Element

Type
Promise.<Element>
Example
element.get({with: 'params'}).then(function(data) {
  // data is here, restified for further use
})

element.get('route', {with: 'params'}).then(function(data) {
  // data is here, restified for further use
})

patch(body, params) → {Promise.<Element>}

Make a PATCH request, PATCHing the body.
For more information on the format of the request, look at Rest._findBodyAndParams

Parameters:
Name Type Description
body Object

The body of the request

params Object

The URL parameters for the request

Source:
See:
Returns:

A Promise that is resolved with an Element

Type
Promise.<Element>
Example
element.patch({name: "Matt Smith"}, {with: 'children'})
element.patch(['name'])
element.patch(['name'], {with: 'children'})
element.patch('name', 'season', {with: 'children'})
element.patch('name', 'season')

post(params) → {Promise.<Element>}

Make a POST request, POSTing the serialized element

Parameters:
Name Type Description
params Object

The URL parameters for the request

Source:
Returns:

A Promise that is resolved with an Element

Type
Promise.<Element>
Example
element.post({with: 'params'}).then(function(data) {
  // data is here, restified for further use
})

put(params) → {Promise.<Element>}

Make a PUT request, PUTing the serialized element

Parameters:
Name Type Description
params Object

The URL parameters for the request

Source:
Returns:

A Promise that is resolved with an Element

Type
Promise.<Element>
Example
element.put({with: 'params'}).then(function(data) {
  // data is here, restified for further use
})