MojitProxy Class
The object that is given to each mojit binder to be used to interact with other mojits and the mojito framework.
Item Index
Methods
broadcast
-
name -
payload -
options
Used by mojit binders to broadcast a message between mojits.
Parameters:
-
nameStringevent name.
-
payloadObjectthe payload for the event.
-
optionsObjectcurrently 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'}}.
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:
-
idStringEither the slot key of the child, or the DOM view id of the child.
-
retainNodeBooleanif true, the binder's node will remain in the dom.
destroyChildren
-
retainNode
Destroys all children. (Calls destroyChild() for each child.)
Parameters:
-
retainNodeBooleanif 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:
-
retainNodeBooleanif 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:
getFromUrl
-
key
Gets URL parameters
Parameters:
-
keyStringThe name of the parameter required.
Returns:
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:
-
actionStringname of the action to invoke.
-
optionsObjectsee above.
-
cbFunctionfunction to be called on completion.
listen
-
name -
callback
Allows mojit binders to register to listen to other mojit events
Parameters:
-
nameStringevent name.
-
callbackFunctioncalled when an event is broadcast with the event data.
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:
-
optsObjectsame as the options for invoke().
-
cbFunctionCalled 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:
-
dataObjectThe data to render.
-
viewStringThe view name to use for rendering.
-
cbFunction(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 optionalname event name.
