Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created July 6, 2011 19:36
Show Gist options
  • Save terrancesnyder/1068137 to your computer and use it in GitHub Desktop.
Save terrancesnyder/1068137 to your computer and use it in GitHub Desktop.
Simple repeater for XHTML forms.
<!-- datasource -->
<xforms:instance id="fruits">
<fruits>
<fruit>Apple</fruit>
<fruit>Orange</fruit>
<fruit>Pear</fruit>
</fruits>
</xforms:instance>
<!-- create repeater -->
<xforms:repeat nodeset="instance('fruits')/fruit/following-sibling::*" id="fruit-repeat">
<xforms:output value="position()"/>
<xforms:input ref=".">
<xforms:label ref="."/>
</xforms:input>
<br/>
</xforms:repeat>
<!-- add button to allow adding a fruit -->
<xforms:trigger>
<xforms:label>Add fruit</xforms:label>
<xforms:insert ev:event="DOMActivate" context="." nodeset="instance('fruits')/fruit"
origin="xxforms:element('fruit')"/>
</xforms:trigger>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment