API Docs for: 0.9.0
Show:

MojitProxy Class

The object that is given to each mojit binder to be used to interact with other mojits and the mojito framework.

Methods

broadcast

(
  • name
  • payload
  • options
)

Used by mojit binders to broadcast a message between mojits.

Parameters:

  • name String

    event name.

  • payload Object

    the payload for the event.

  • options Object

    currently only used to specify target for broadcast. For example, to target only one child mojit for broadcast, use: {target: {slot: 'slot name', viewId: 'DOM view id'}}.

data.get

(
  • name
)
Any

Returns the value of the specified attribute.

Parameters:

  • name String

    Attribute name.

Returns:

Any: Attribute value, or undefined if the attribute doesn't exist.

data.set

(
  • name
  • value
  • [options]
)
chainable

Sets the value of a single attribute.

Parameters:

  • name String

    Attribute name.

  • value Any

    Value to set.

  • [options] Object optional

    Data to be mixed into the event facade of the change event(s) for these attributes.

    • [silent=false] Boolean optional

      If true, no change event will be fired.

destroyChild

(
  • id
  • retainNode
)

Clears out a child's view, calling the appropriate life cycle functions, then destroy's its binder and dereferences it. Will also dereference the child from this mojit's children.

Parameters:

  • id String

    Either the slot key of the child, or the DOM view id of the child.

  • retainNode Boolean

    if true, the binder's node will remain in the dom.

destroyChildren

(
  • retainNode
)

Destroys all children. (Calls destroyChild() for each child.)

Parameters:

  • retainNode Boolean

    if true, the binder's node will remain in the dom.

destroySelf

(
  • retainNode
)

Allows a binder to destroy itself and be removed from Mojito client runtime entirely.

Parameters:

  • retainNode Boolean

    if true, the binder's node will remain in the dom.

getChildren

() Object

Helper function to gather up details about a mojit's children from the Mojito Client.

Returns:

Object: slot <String>-->child information <Object>.

getFromUrl

(
  • key
)
String | Object

Gets URL parameters

Parameters:

  • key String

    The name of the parameter required.

Returns:

String | Object: param value, or all params if no key specified.

invoke

(
  • action
  • options
  • cb
)

Used by the mojit binders to invoke actions on themselves within Mojito. The options parameter is optional and may contain:

params
<object> must be broken out explicitly:
route
<object> Map of key/value pairs.
url
<object> Map of key/value pairs.
body
<object> Map of key/value pairs.
file
<object> Map of key/value pairs.
rpc
<boolean> Means that we are immediately sending the request to the server to answer the invocation.

Parameters:

  • action String

    name of the action to invoke.

  • options Object

    see above.

  • cb Function

    function to be called on completion.

listen

(
  • name
  • callback
)

Allows mojit binders to register to listen to other mojit events

Parameters:

  • name String

    event name.

  • callback Function

    called when an event is broadcast with the event data.

pageData.get

(
  • name
)
Any

Returns the value of the specified attribute.

Parameters:

  • name String

    Attribute name.

Returns:

Any: Attribute value, or undefined if the attribute doesn't exist.

pageData.set

(
  • name
  • value
  • [options]
)
chainable

Sets the value of a single attribute.

Parameters:

  • name String

    Attribute name.

  • value Any

    Value to set.

  • [options] Object optional

    Data to be mixed into the event facade of the change event(s) for these attributes.

    • [silent=false] Boolean optional

      If true, no change event will be fired.

refreshView

(
  • opts
  • cb
)

Refreshes the current DOM view for this binder without recreating the binder instance. Will call the binder's onRefreshView() function when complete with the new Y.Node and HTMLElement objects.

Parameters:

  • opts Object

    same as the options for invoke().

  • cb Function

    Called after replacement and onRefreshView have been called, sends data/meta.

render

(
  • data
  • view
  • cb
)

This method renders the "data" provided into the "View" specified. The "view" must be the name of one of the files in the current Mojits "views" folder. Returns via the callback.

Parameters:

  • data Object

    The data to render.

  • view String

    The view name to use for rendering.

  • cb Function(err,str)

    The callback function.

unlisten

(
  • [optional]
)

The opposite of the "listen" function. Deletes all callback functions from the listener queue associated with this binder and event type. If event name is not specified, all callbacks associated with this binder are deleted.

Parameters:

  • [optional] String optional

    name event name.

Properties

config

Object

The mojit configuration for this binder

context

Object

The context used to generate this page

data

Model.Vanilla

The mojit data model, for getting and setting data that is shared by a single mojit controller, binder, and/or template. Use this.data.get() and this.data.set(). See also http://yuilibrary.com/yui/docs/api/classes/Model.html and https://developer.yahoo.com/cocktails/mojito/docs/topics/mojito_data.html#sharing-data

pageData

Model.Vanilla

The page data model, or getting and setting data that is shared between mojits on a page. Use this.pageData.get() and this.pageData.set(). See also http://yuilibrary.com/yui/docs/api/classes/Model.html and https://developer.yahoo.com/cocktails/mojito/docs/topics/mojito_data.html#sharing-data

proxied

Object

The config of a child which this mojit is proxying.