To what components the xxforms-iteration-moved
is dispatched is a matter of how xxforms-iteration-moved
is defined. Right now, it is dispatched to controls inside iterations that moved. What you might need is to handle the xforms-enabled
event, in addition to xxforms-iteration-moved
. Consider the following example: you start with a list with "a, c, d". If you insert "b" after "a", then the new "b" gets an xforms-enabled
and "c, d" each get a xxforms-iteration-moved
. So by reacting to both events, you should be able to (re)initialize your component as necessary.
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
<xhtml:head>
<xhtml:title>Iteration moved</xhtml:title>
<xforms:model>
<xforms:instance>
<instance>
<letter>a</letter>
<letter>c</letter>
<letter>d</letter>
<letter>e</letter>
</instance>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<fr:button>
<xforms:label>Insert b</xforms:label>
<xforms:insert ev:event="DOMActivate" nodeset="letter" at="1" position="after" origin="xxforms:element( letter , b )"/>
</fr:button>
<fr:button>
<xforms:label>Delete c</xforms:label>
<xforms:delete ev:event="DOMActivate" nodeset="letter[. = c ]"/>
</fr:button>
<xforms:repeat id="letter-repeat" nodeset="letter">
<xforms:output id="letter" value=".">
<xforms:message ev:event="xxforms-iteration-moved" level="modal" value="concat( xxforms-iteration-moved : , .)"/>
<xforms:message ev:event="xforms-enabled" level="modal" value="concat( xforms-enabled : , .)"/>
</xforms:output>
</xforms:repeat>
</xhtml:body>
</xhtml:html>
I should add that if you expect your component to be used in a repeat (and sooner or later every component is), right now, because of how repeats work on the client side, if you are doing some work to initialize the component on xforms-enabled
, you most likely need to do that as well on xxforms-iteration-moved
. For instance, see how this is done in the fr:button
component.