< XSLTForms

A common cause of triggers not working is that the actions in the trigger are not listening for any events.

The following trigger illustrates the problem. It is meant, when activated, to replace the value of the current element with the string "Hello <strong>World</strong>!". But nothing happens when the trigger is pressed.

<trigger xmlns="http://www.w3.org/2002/xforms">
    <label>Hello World!</label>
    <setvalue ref="."
              value="'Hello &lt;strong&gt;World&lt;/strong&gt;!'"
              />
</trigger>

The solution is to specify the event(s) which will cause the setvalue action to fire.

<trigger xmlns="http://www.w3.org/2002/xforms">
    <label>Hello World!</label>
    <setvalue ev:event="DOMActivate"
              xmlns:ev="http://www.w3.org/2001/xml-events"
              ref="."
              value="'Hello &lt;strong&gt;World&lt;/strong&gt;!'"
              />
</trigger>
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.