Data bindings are reasonably fast, but they are not free. If you create lots of bound properties, pretty soon your application will slow down.
Fortunately, for many applications, you often don't need the full power of 'hot' bindings - the data is read-only, and never updated during the lifetime of the page. For these situations, you can use a different runtime expression part - #get - instead of #bind. Its semantics are similar to #bind, except that the data is only retrieved once, when the control is created.
The values above are specified in the same manner as those in the first binding example, except they are only retrieved once.
Further, Jitsu is smart about simple controls that contain #get expressions. If a Label, or img tag, are declared that only use #get or static property sets, the compiler will render the html directly rather than creating a control, which will further minimize runtime overhead.
#get has a limitation that one needs to be aware of. Its path must refer to the outermost data object of its containing template. You cannot, for example, do the following:
<j:App> <j:data> <j:DataSet id="people" src="file:tour_data.xml#people"/> </j:data> <!-- use a Details control to point to a particular object --> <j:Details item="#bind(data.people.fred)"> <!-- now bind against "item.propertyName" to get properties --> First: <j:Label text=;"#get(item.firstName)"/> <br/> </j:Details> </j:App>
This is because the item property refers to a property on the Details object, not on the app. The item property of the Details object will not have been set up correctly at the time the #get is evaluated. [TODO should all binding containers be required to use templates?]