Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

Motivation

You want to catch a deselection event when you navigate away from a page.

Sample Code

<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<title>Demo of Deselection Event</title>
<style type="text/css">
@namespace xf url("http://www.w3.org/2002/xforms");
body {font-family: Helvetica, sans-serif;}
/* style each individual tab */
#tab-bar xf|trigger {
color: black;
border: 3px outset gray;
border-bottom: none;
font-weight: bold;
margin-right: 5px;
padding: 0.2em;
/* round the top corners - works only with FireFox */
-moz-border-radius: .5em .5em 0em 0em;
}
</style>
<xf:model id="image">
<xf:instance xmlns="" id="image">
<data/>
</xf:instance>
</xf:model>

</head>
<body>
<h1>Deselection Events Demo</h1>
<p>The deselection event will generate a message each time a new tab is selected.</p>
<div id="tab-bar">
<xf:trigger appearance="minimal">
<xf:label>Image Tab</xf:label>
<xf:toggle case="image-tab" ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger appearance="minimal">
<xf:label>Metadata for Image Tab</xf:label>
<xf:toggle case="metadata-tab" ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger appearance="minimal">
<xf:label>Rights Tab</xf:label>
<xf:toggle case="rights-tab" ev:event="DOMActivate"/>
</xf:trigger>
</div>

<xf:switch>
<xf:case id="image-tab">
<xf:message level="modal" ev:event="xforms-deselect">Deselecting Image Tab</xf:message>
<h1>Image Tab</h1>
<xf:input>
<xf:label>Alt text:</xf:label>
</xf:input>
<xf:select1 appearance="minimal">
<xf:label>Image Type:</xf:label>
<xf:message level="modal" ev:event="xforms-deselect">select1 deselect</xf:message>
<xf:message level="modal" ev:event="DOMFocusOut">DOM Focus Out</xf:message>
<xf:item>
<xf:label>Photo</xf:label>
<xf:value>Photo</xf:value>
</xf:item>
<xf:item>
<xf:label>Logo</xf:label>
<xf:value>Logo</xf:value>
</xf:item>
<xf:item>
<xf:label>Other</xf:label>
<xf:value>Other</xf:value>
</xf:item>
</xf:select1>
<xf:input>
<xf:label>Caption</xf:label>
</xf:input>
<xf:textarea>
<xf:label>CMS description</xf:label>
</xf:textarea>
</xf:case>
<xf:case id="metadata-tab">
<xf:message level="modal" ev:event="xforms-deselect">Deselecting Metadata Tab</xf:message>
<h1>Metadata Tab</h1>
</xf:case>
<xf:case id="rights-tab">
<xf:message level="modal" ev:event="xforms-deselect">Deselecting Rights Tab</xf:message>
<h1>Metadata Tab</h1>
<xf:label>Rights details</xf:label>
<xf:help>State the rights ownership of this feature.</xf:help>
<xf:input>
<xf:label>Rights owner</xf:label>
<xf:help>
<p class="instructions">'BBC' is set as the default. Only set an owner if
there are particular requirements</p>
</xf:help>
</xf:input>
<xf:select1 appearance="minimal">
<xf:label>Rights status</xf:label>
<xf:item>
<xf:label>Free</xf:label>
<xf:value>free</xf:value>
</xf:item>
<xf:item>
<xf:label>Copyrighted</xf:label>
<xf:value>copyrighted</xf:value>
</xf:item>
</xf:select1>
<xf:textarea>
<xf:label>Rights notes:</xf:label>
</xf:textarea>
</xf:case>
</xf:switch>
</body>
</html>

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.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
The triggers refer to the instance. If a tab in the instance has a selected attribute set to "true" the corresponding trigger is "enabled" the other triggers are disabled (and by default not visible). They are made visible in the CSS statement for the disabled triggers. Two additional lines are need
CC BY-SA 4.0
<bookmarks> <section name="Book Homepage"> <bookmark href=" name="XForms Tutorial and Cookbook"></bookmark> </section> <section name="Introduction"> <bookmark href=" name="Background"></bookmark> <bookmark href=" name="Benefits"></bookmark> <bookmark href=" name="Installing and Testing"></bookmark>
CC BY-SA 4.0
Note that in the model there are a series of actions, each with their own event name: model id="data_model"> ... ev:event="addItemEvent"> ... These events are called directly inside of a trigger like this: name="addItemEvent" target="data_model" /> Note that the target attribute is the name of the m
CC BY-SA 4.0
XForms also allows a user to read data into a form using a HTTP **get** and to write data from a file using HTTP **put** operations using a remote web server. Just make sure you enable put operations on your web server and that the file you are putting is writeable This means you will need to do a c
CC BY-SA 4.0
This example will show you how to save intermediate form data to a local disk. Sometimes long forms take a while to fill out. You would like to allow users to fill out part of a form, log off, and resume their form when they return. Sometimes this intermediate data can be used as a default template
CC BY-SA 4.0
XForms, Tri-Document Loading