Hub Nexus
Aggiornato

AutoreAncora senza autorePrendila in carico

Vedi qualcosa da migliorare? Proponi una modifica.

Sostegno

Motivation

You want to have a region of your page that changes images when the user selects a button.

Method

Store a list of links to the slide images in an instance. Use another instance variable to store the state of the images is currently selected. Use a trigger to update the image number.

Load XForms Application

Sample Source Code

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ev="http://www.w3.org/2001/xml-events">;

Slide Show
id="data-model">
id="data" xmlns="">

href="http://www.bav-astro.de/sterne/monv838/monv838-hubble-20040304.jpg">Image 1
href="http://aether.lbl.gov/Images/resizenowmap.jpg">Image 2
href="http://www.nasa.gov/images/content/143744main_hubble_spiral_2006.jpg">Image 3
href="http://www.space.gc.ca/asc/img/sci_core-hubble.jpg">Image 4

nodeset="instance('data')/link/@href" type="xs:anyURI"/>
id="state" xmlns="">

0

ev:event="cycle-next">
ref="instance('state')/cycle" value="(. + 1) mod 4"/>
name="update-model" target="data-model"/>

ev:event="update-model">

Next
ev:event="DOMActivate">
name="cycle-next" target="data-model"/>

ref="instance('state')/cycle"/>) ref="instance('data')/link[1 + instance('state')/cycle]"/>

ref="instance('data')/link[1 + instance('state')/cycle]/@href" mediatype="image/*"/>

Discussion

This program has the Next trigger calls the "cycle-next" named event when it is pressed. This event, which is defined in the model, updates the cycle and resets it back to one after the slides are done. After that it instructs the form to recalculate its dependency graph. This updates the visible image.

Note that the output must have a the mediatype set to be image/* for the browser to render the link as an image correctly.

Attribution

This example was created by Chris Wallace and the University of Western England.

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.

In queste pubblicazioniXForms

LingueEnglish

Licenza: CC BY-SA 4.0 · Tratto da en.wikibooks.org

1

0

0

0

Spinner Logo

Commenti

Spinner Logo
Versione: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
Versione: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
Versione: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
Versione: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
Versione: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
Versione: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs