mobile.widget._Widget
mobile.widget._Widget
is the object all mobile widgets must inherit of. The mobile widget lifecycle documentation can be found here.
Properties
Widget properties should be accessed using the _Widget.set
and _Widget.get
functions.
mxid
This is the unique id for the widget.
Example: “54015330-4ce4-4346-8d0a-1ff92bfb5c99”
mxform
This is a reference to the containing form, see mobile.lib.Form.
mxconfig
This is the config for the widget, as defined in the Modeler.
mxcontext
This is the current context, see mendix.lib.MxContext.
suspended
Whether the widget is suspended. Suspended widgets do not update themselves.
disabled
Whether the widget is disabled. Disabled widgets do not allow editing.
Methods
getTemplate(name)
This method is called to get a template defined for this widget.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the template. |
Returns
Type | Description |
---|---|
DomNode | The template DOM. |
parseContent(node, params)
Instantiates all widgets at or under node
, passing the given parameters. If the widget’s doparse
property is false, no widgets are instantiated. Only div
nodes are considered.
Parameters
Name | Type | Description |
---|---|---|
node | DOMNode | The root for node to start parsing. |
params | Objects | Parameters that will be mixed in with each instantiated widget. |
Returns
Type | Description |
---|---|
Array | The instantiated widgets. |
getChildren(nested)
Retrieve child widgets.
Parameters
Name | Type | Description |
---|---|---|
nested | Boolean | Whether to only retrieve direct children, or all children recursively. |
Returns
Type | Description |
---|---|
Array | The requested child widgets. |
translate(str, args, fallback)
Retrieve a string translation.
Parameters
Name | Type | Description |
---|---|---|
str | String | Identifier for the string to translate. |
args | Array | Values to expand in the translated string. |
fallback | String | String to use when translation was not found. |
Returns
Type | Description |
---|---|
String | The requested translation. |
applyContext(context, callback)
This method is called to apply a given context to the widget. If the widget does not implement applyContext, its update method will be called with two paramenters: the object from the context, and the callback.
Parameters
Name | Type | Description |
---|---|---|
context | MxContext | The context to apply. |
callback | Function | The function to be called when finished. |
passContext(widgets, context, callback)
This method is called to distribute the context to a list of widgets. This will invoke applyContext on all widgets in the list.
Parameters
Name | Type | Description |
---|---|---|
widgets | Array | The list of widgets to apply context to. |
context | MxContext | Optional. If not given, the current context of the widget will be used. |
callback | Function | The function to be called when finished. |
subscribe(sub)
Alias of mx.data.subscribe, but it also checks for redundant subscribes, and automatically removes all subscribes when the widget gets destroyed.
unsubscribe(handler)
Alias of mx.data.unsubscribe.
listen(message, callback)
Alias of mobile.lib.Form.listen, but it also automatically removes all listeners when the widget gets destroyed.
unlisten(handler)
Alias of mobile.lib.Form.unlisten.
collect(chain, callback)
Alias of mendix.lang.collect, but it automatically uses the widget’s scope.
sequence(chain, callback)
Alias of mendix.lang.sequence, but it automatically uses the widget’s scope.
resume()
Stub function, implement this method to do something when the widget is resumed.
suspend()
Stub function, implement this method to do something when the widget is suspended.
Parameters
Name | Type | Description |
---|---|---|
value | Boolean | Whether to enable or disable the widget. |
enable()
Stub function, implement this method to do something when the widget is enabled.
disable()
Stub function, implement this method to do something when the widget is disabled.
addOnLoad(handler)
This method is called to add a function to be called when the widget is loaded.
Parameters
Name | Type | Description |
---|---|---|
handler | Function | Function to be called when the widget is loaded. |
addOnDestroy(handler)
This method is called to add a function to be called when the widget gets destroyed.
Parameters
Name | Type | Description |
---|---|---|
handler | Function | Function to be called when the widget gets destroyed. |
destroy()
This method is called when the widget gets destroyed. Do NOT overwrite this method, use the uninitialize method for widget cleanup.
uninitialize()
This method is called when the widget gets destroyed, use this method for widget cleanup.