databinding-$11.lzx

<canvas height="150" width="100%">
  <dataset name="colors">
    <value>red</value>
    <value>green</value>
    <value>olive</value>
    <value>yellow</value>
    <value>blue</value>
    <value>teal</value>
  </dataset>

  <simplelayout spacing="10"/>
  <view name="swatch" width="200" height="30" datapath="colors:/value[1]/text()">
    <method name="applyData" args="v">
      acceptAttribute('bgcolor', 'color', v);
      display.setAttribute('text', v)
    </method>
  </view>
  <text name="display" resize="true"/>

  <button text="Change view color">
    <attribute name="ind" value="$once{1}"/>
    <handler name="onclick">
      if (++ind == 7) ind = 1
      swatch.setAttribute('datapath', 'colors:/value[' + ind + ']/text()')
    </handler>
  </button>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2008 Laszlo Systems, Inc.  All Rights Reserved.                   *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->

Cross References

Named Instances