Motivation
You want to be able to perform various tasks at various part of the form execution.
Method
XForms is integrated with the W3C XML Event standard. This standard creates standard names for almost
all of the common events used in the lifecycle of a form. The W3C has attempted to standardize these events
and their event labels so that they can be used consistently across browsers from all vendors.
XML Event Types
The following is a listing of the XForms events. Some events are tied to individual forms controls such as input, select and textarea and some are tied to the model within the form.
| Event | Cancel | Bubbles | Target |
|---|---|---|---|
| Initialization Events | |||
| xforms-model-construct | N | Y | |
| xforms-model-construct-done | N | Y | |
| xforms-ready | N | Y | |
| xforms-model-destruct | N | N | |
| Processing Events | |||
| xforms-rebuild | Y | Y | |
| xforms-recalculate | Y | Y | |
| xforms-revalidate | Y | Y | |
| xforms-refresh | Y | Y | |
| Interaction Events | |||
| xforms-previous | Y | N | |
| xforms-next | Y | N | |
| xforms-focus | Y | N | |
| xforms-help | Y | Y | |
| xforms-hint | Y | Y | |
| xforms-reset | Y | Y | |
| xforms-submit | Y | Y | |
| DOMActivate | Y | Y | |
| Notification Events | |||
| DOMFocusIn | N | Y | |
| DOMFocusOut | N | Y | |
| xforms-value-changed | N | Y | |
| xforms-select | N | Y | , or |
| xforms-deselect | N | Y | , or |
| xforms-scroll-first | N | Y | |
| xforms-scroll-last | N | Y | |
| xforms-insert | N | Y | |
| xforms-delete | N | Y | |
| xforms-valid | N | Y | |
| xforms-invalid | N | Y | |
| xforms-in-range | N | Y | |
| xforms-out-of-range | N | Y | |
| xforms-readonly | N | Y | |
| xforms-readwrite | N | Y | |
| xforms-required | N | Y | |
| xforms-optional | N | Y | |
| xforms-enabled | N | Y | |
| xforms-disabled | N | Y | |
| xforms-submit-done | N | Y | |
| xforms-submit-error | N | Y | |
| Error Notifications | |||
| xforms-binding-exception | N | Y | |
| xforms-link-exception | N | Y | |
| xforms-link-error | N | Y | |
| xforms-compute-exception | N | Y |
Displaying Events in a Log File
One of the best ways to learn about how events get fired is to write them to a log instance and display the log at the
bottom of the form. You can do this logging while you are building and debugging your form.
Add the following instance to your model:
xmlns="" id="log">
log initialized
Whenever you want to see an event, just add an action that appends an event to the end of the log:
ev:event="xforms-deselect">
nodeset="instance('log')/event" at="last()" position="after" />
ref="instance('log')/event[last()]" value="'Tab One deselected'" />
Note that the message must be inside a pair of single quotes inside of double quotes.
At the end of the form you can display the data from the log instance by enclosing the output within a repeat.
id="event-log">
nodeset="instance('log')/event" class="log">
ref="." />
You can also style the event log with the following
#event-log {
color: DarkGray;
background-color: Lavender;
}
Where this page came from
This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.
Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.
收录于这些专栏XForms
许可协议: CC BY-SA 4.0 · 改编自 en.wikibooks.org
1
0
0
0

留言






