Using Zen Mojo
Interacting with Layout Objects
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

This chapter describes how to interact with layout objects currently displayed on a Zen Mojo page. It discusses the following:

Note:
The JQuery Mobile Helper plugins and the HTML5 Helper plugin also provide methods associated with the layout objects. These methods include $show() and $hide(). Such methods will be provided in all plugins in future releases, if possible. For details, see the applicable chapters of Using Zen Mojo Plugins.
Methods in This Chapter
The methods in this chapter are methods of each documentView instance. To invoke one of these methods from a client method, use a couple of steps like the following:
var mainView = zen('mainView');
mainView.methodname();
In the first line, zen('mainView') is a reference to the documentView whose id is 'mainView'. The second line invokes a method associated with that documentView.
Getting or Setting the Value of a Layout Object
Use the following methods of the documentView to get or set values of layout objects:
getControlValue()
ClientMethod getControlValue(key, level) [ Language = javascript ]
Returns the value of the layout object that has given key, for the given level of the document stack.
setControlValue()
ClientMethod setControlValue(key, value, level) [ Language = javascript ]
Sets the value of the layout object that has the given key, for the given level of the document stack. This method does not fire a change event.
setItemValue()
ClientMethod setItemValue(key, value, level) [ Language = javascript ]
Sets the value of the layout object that has the given key, for the given level of the document stack. This method does not fire a change event.
Refreshing a Layout Object
To refresh a single layout object, use the following method of the documentView:
refreshItem()
ClientMethod refreshItem(key, level) [ Language = javascript ]
Re-renders the HTML for the layout object that has the given key, for the given level of the document stack.
Or invoke the $refresh() method of the layout object.
Note that most but not all layout objects can be refreshed. In some cases, there is no practical scenario for refreshing an object, so a few objects simply ignore these methods. The plugin reference documentation indicates which layout objects can be refreshed.
Accessing a Layout Object
Sometimes it is necessary to access a layout object directly. To do so, use the following method of the documentView:
getItemByKey()
ClientMethod getItemByKey(key, level) [ Language = javascript ]
Returns the layout object that has the given key, for the given level of the document stack.
This method is useful for layout objects that provide methods. The JQuery Mobile Helper plugins and the HTML5 Helper plugin provide such methods, which include $show() and $hide(). Such methods will be provided in all plugins in future releases, if possible. For details, see the applicable chapters of Using Zen Mojo Plugins.