XForms/Disable Trigger

Motivation
There is a specific delete trigger on each row of a table or each item of a list. You want to disable the delete (button) trigger if there is only a single item remaining in the list.

Sample Code
       Item:    Delete    <xf:trigger> <xf:label>Append</xf:label> <xf:action ev:event="DOMActivate"> <xf:insert nodeset="instance('my-instance')/item" at="last" position="after" /> <xf:setvalue ref="instance('my-instance')/item[last]" value="concat('Item ', count(instance('my-instance')/item))" /> </xf:action> </xf:trigger> <xf:trigger bind="item-delete-trigger"> <xf:label>Delete Selected Row</xf:label> <xf:delete nodeset="instance('my-instance')/item[index('item-repeat')]" ev:event="DOMActivate" /> </xf:trigger>

Discussion
This example uses two named instances. The my-instance is the data that would be submitted with the form. The views instance is just used to bind a view of the form with some logic. This is done in a bind statement.

This says that the item delete trigger should only be present if there is more than one item.

Although the above is logically correct, there is really no need to count all the items and do a comparison. You can enable the trigger if the second item is present.

This syntax is preferred since it is faster and the greater than sign does not have to be escaped.