Xforms Cancel Event

95 Views Asked by At

This ability seems to be advertised all over the place for xforms but I can't get it to work. It appears 'ev:defaultAction="cancel"' is the way to go, but I've tried putting it within xform control elements, within action elements, within the model element. I am trying to make it so that when a click on a xf:repeat item occurs, rather than the index changing, the nodeset changes. So I figured it would be easy to just intercept the event, but I can't figure it out.

For a test I tried stopping all interaction events within the entire document. This placed inside the model element doesn't work:

<xf:action ev:event="DOMActivate" ev:defaultAction="cancel"/>

Nor does this:

<xf:model id="master" ev:event="DOMActivate" ev:defaultAction="cancel">

This won't stop a repeat from indexing:

<xf:repeat ... ev:event="DOMActivate" ev:defaultAction="cancel"/>

Nor this:

<xf:repeat ...>
     <script type="text/javascript" ev:event="DOMActivate" ev:defaultAction="cancel"/>
</xf:repeat>

I am using Betterform. This placed within the model element doesn't cancel the default action or even fire at all.

<xf:action ev:event="betterform-index-changed"         
ev:target="repeat" ev:defaultAction="cancel"> 

What am I missing with these events? The specification makes it sound very straight forward. xforms-recalculate is the only event I've been able to successfully cancel so far and its the one used in many examples to stop that specific automatic process. There are very few general examples of changing default actions and sequencing of events while they bubble up and down elements.

1

There are 1 best solutions below

0
On

Several things are wrong here in with your examples.

You can't cancel a DOMActivate on the model as it does not receive this event at all. Further you can apply event attributes only to XForms action elements (e.g. action, setvalue, insert etc.). The listener is always attached to the parent element - this will receive the event.

Some events are cancelable and some not. The betterform-index-changed event for instance is not cancelable. For the other XForms events you see their definitions here: http://www.w3.org/TR/2009/REC-xforms-20091020/#rpm-events