Faton
Faton

Reputation: 873

How to get a value on event xxforms-value-changed?

I would like to get the value and the name of the element(or ID) when a value has changed in fr-form-instance? I've added the followling in "fr-form-modal" :

<xforms:model id="fr-form-model">

                  ...
                  ...

    <xforms:action ev:event="xxforms-value-changed" ev:observer="fr-form-instance"> 
          <xxforms:variable name="changed-value" select="."/>//doesn't work
          //get name(or id) if possible
    </xforms:action>

                  ...
                  ...

</xforms:model>

The variable $changed-value is empty. Is there a way to accomplish this?

Upvotes: 1

Views: 1797

Answers (2)

ebruchez
ebruchez

Reputation: 7857

It seems that the xxforms-value-changed event does not provide useful event context information. So as things stand, this event does not allow you to retrieve the element or attribute that has change. I have committed a change to support this.

In the meanwhile, you could instead listen to xforms-value-changed events in the UI, for example on an outer <xforms:group>. This will work for nodes that have controls bound to them.

Upvotes: 5

Jayy
Jayy

Reputation: 2436

As ebruchez said you can use <xforms:group> in the body and observe the events. Below sample works.

    <xhtml:html>
    <xforms:model>
        ..
        ..
        ..

        <xforms:action ev:observer="all-fields"  ev:event="xforms-value-changed"> //you can list as many events as you wish to observe for the fields inside "all-fields" group.
            <xforms:message level="modal" value="event('xxforms:binding')" /> //This will show you the value which has got changed.
        </xforms:action>


    </xforms:model>

    <xhtml:body>
        <xforms:group id="all-fields">
            ...
            ...
            ...

        </xforms:group>
    </xhtml:body>
</xhtml:html>

Reference: http://wiki.orbeon.com/forms/doc/developer-guide/xforms-events

Upvotes: 2

Related Questions