Get Properties or Property Values
The default app package that you download from the App Editor includes a basic example of retrieving the value of an app property and rendering this in the app.
Note: | For links to other custom app examples, click More... above. |
Hello World defines the property in its App Specification and a default value for the property:
<?xml version="1.0" encoding="UTF-8"?>
<app id="hello-world" name="Hello World"
jsclass="Sample.Hello"
height="200" width="200"
draggable="false" minimizable="false">
<title>Hello World</title>
<description>The Hello World App</description>
<properties>
<property name="helloString" datatype="string"
defaultvalue="Techies !" label="Hello String">
<description>Hello String</description>
</property>
</properties>
<requires>
<require name="jquery" type="library"/>
<require src="js/app.js" type="script"/>
<require src="html/app.html" type="html"/>
</requires>
</app>
The Sample.HelloWorld class uses the getPropertyValue(name) method in the MashZone NextGen App API to retrieve the property’s value and render this in the app:
Sample.Hello = function( app ) {
jQuery( app.rootElement ).find( '.helloString' ).html(
app.getPropertyValue( 'helloString' )
);
};
There are several other methods you can use in custom apps to retrieve or manipulate properties, such as getProperty(name) or getPropertyNames(). See the MashZone NextGen API Reference for details.