Iterator
Trace: » Modal » Extending Entourage Expressions » Entourage Service Brokers » Datepicker » Iterator

Iterator

Provides a mechanism for repeating data bound templates.

Demo

  • #{name}

Source Code

<ul control="iterator[property=rows]" on="l:iterator then render">
  <li id="item_#{iterator_index}" on="click then script[alert('#{name}')]">#{name}</li>
  <script>
    if ('#{name}' == 'Neil Patrick Harris') {
      jQuery("#item_#{iterator_index}").css("color", "red");
    }
  </script>
</ul>
 
<script>
$MQL("l:app.compiled", function() {
  $MQ('l:iterator',{'rows':[
    {name:'Neil Patrick Harris'},
    {name:'Fred Savage'},
    {name:'Kirk Cameron'}
  ]});
});
</script>

Script Example

Create the control…

App.createControl(
	'myItertator',
	'iterator',
	{
	},
	function()
	{
	}
);

Get the handle to an instance of the control and save it to a local variable and set an Entourage Message listener to render the iterator using an arbitrary payload.

var iteratorInstance = null;
 
App.getControl('api_1','iterator',function()
{
	iteratorInstance = this;
});
 
$MQL('l:testapi1',function()
{
	var d =[{name:'api_1'},{name:'api_2'},{name:'api_3'}];
	iteratorInstance.render({'rows':d})
});

Options

The iterator control is made up of a container div and may contain any arrangement of markup which will act as it's template. The control tag on the div indicates what kind of widget the div will become. The widget identity can accept the following initial parameters…

Initial options supported by the widget.

Option Description Default Type
template Set the template for each row null String
items reference to array within row null String
property Property for implicit model null String

Actions/JavaScript API

Functions either accept a single argument such as an integer or a string, otherwise they accept a one dimensional object literal. Any function that can be called as an action accepts the same parameters but in the action parameter format.

Function Action Description
render(obj) render Renders the iterator with a specified dataset. If this function is called as an action, the dataset is retrieved from the message that invoked it.
execute(obj) execute Rebuilds the iterator using the initial settings, and any additional that are specified from a either a message or an object.
ui/widgetiterator.txt · Last modified: 2009/03/10 16:07 by kwhinnery