Class Context

The context reflects a component’s client-side state. It gives access to other important libraries like client storage, messaging and web sockets.

Constructor

class Context(raintimeInstance, component)
Arguments:
  • raintimeInstance (Raintime) –
  • component (Component) – the component object

Methods

getRoot

Context#getRoot()
Returns jQueryElement:
 The component’s container jQuery element

Returns the DOM container element for the component associated with this view context.

insert

Context#insert(component, dom[, callback])
Arguments:
  • component (Object) – The component which to be requested
  • component.id (String) – The component id
  • component.view (String) – The component view id
  • component.sid (String) – The component staticId id
  • component.context (Object) – Custom data for the template
  • component.placeholder (Boolean) – Enable / Disable placeholder
  • dom (jQueryDom) – The dom object where the component is inserted
  • callback (Function) – the function to be called after the controller was loaded

Insert a new component into the given DOM Element and set a function that will be called after the controller for the new controller was loaded.

The context for the callback function will be the component’s controller.

remove

Context#remove(staticId)
Arguments:
  • staticId (String) – the child static id

Removes a child component.

replace

Context#replace(component[, callback])
Arguments:
  • component (Object) – The component which to be requested
  • component.id (String) – The component id
  • component.view (String) – The component view id
  • component.sid (String) – The component staticId id
  • component.context (Object) – Custom data for the template
  • component.placeholder (Boolean) – Enable / Disable placeholder
  • callback (Function) – the function to be called after the controller was loaded

Replaces the component from where it is called with the given component and set a function that will be called after the controller for the new component was loaded.

The context for the callback function will be the component’s controller.

Attributes

instanceId

instanceId

the component’s instance id

messaging

messaging

Provides methods to publish and subscribe to events.

storage

storage

the local storage manager

Table Of Contents

Previous topic

Class ClientStorage

Next topic

Class CssRegistry