<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
  <title>Options | JavaScript Examples | UIZE JavaScript Framework</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="keywords" content="Uize.Widget.Options"/>
  <meta name="description" content="See how to use the options widget to let the user pick a single option from a set of options by clicking on an option button. Test links are provided."/>
  <link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href=""/>
  <link rel="stylesheet" href="../css/page.css"/>
  <link rel="stylesheet" href="../css/page.example.css"/>
  <link rel="stylesheet" href="css/option-buttons-set.css"/>


<script type="text/javascript" src="../js/Uize.js"></script>

<h1 class="header">
  <a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
  <a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>

<div class="main">
  <h1 class="document-title">
    <a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
    <div class="pageActionsShell">
      <div id="page-actions" class="pageActions"><a href="source-code/options.html" class="buttonLink">SOURCE</a></div>

  <!-- explanation copy -->

  <div class="explanation">
    <p>In this example, the markup for an options widget is being wired up by an instance of <a href="../reference/Uize.Widget.Options.html"><code>Uize.Widget.Options</code></a>. Below the options are some links that execute snippets of code to demonstrate the programmatic interface of the widget. The <code>Uize.Widget.Options</code> class provides <code>value</code> and <code>tentativeValue</code> state properties in its interface. The <code>Changed.value</code> and <code>Changed.tentativeValue</code> instance events for these two properties can be used to watch for changes in the widget's state. The <code>value</code> state property can be set to programmatically change the selected option. Interact with both the options UI and the test links to see how they affect one another.</p>

  <!-- options UI -->

  <table class="optionsShell" cellspacing="0" cellpadding="0">
      <td><div id="page_options_option0" class="button">SOLAR</div></td>
      <td><div id="page_options_option1" class="button">WIND</div></td>
      <td><div id="page_options_option2" class="button">GEOTHERMAL</div></td>
      <td><div id="page_options_option3" class="button">EFFICIENCY</div></td>
      <td><div id="page_options_option4" class="button">TIDAL</div></td>

  <!-- programmatic interface examples -->

  <div class="programmaticInterface">
    <p><b>options.get ('value') == </b> '<span id="page-optionsValue"></span>'</p>
    <p><b>options.get ('tentativeValue') == </b> '<span id="page-optionsTentativeValue"></span>'</p>
      <b>Set the value for the options widget: </b>
      <a href="javascript://" class="linkedJs">options.set ({value:'solar'})</a>
      <a href="javascript://" class="linkedJs">options.set ({value:'wind'})</a>
      <a href="javascript://" class="linkedJs">options.set ({value:'geothermal'})</a>
      <a href="javascript://" class="linkedJs">options.set ({value:'efficiency'})</a>
      <a href="javascript://" class="linkedJs">options.set ({value:'tidal'})</a>

<script type="text/javascript">

Uize.require (
  function () {
    'use strict';

    /*** create the example page widget ***/
      var page = = UizeSite.Page.Example ({evaluator:function (code) {eval (code)}});

    /*** add the options child widget ***/
      var options = page.addChild ('options',Uize.Widget.Options);

    /*** some code for demonstrating the widget's programmatic interface ***/
      options.wire ({
          function () {page.setNodeInnerHtml ('optionsValue',options)},
          function () {page.setNodeInnerHtml ('optionsTentativeValue',options.get ('tentativeValue'))}

    /*** wire up the page widget ***/
      page.wireUi ();

    /*** initialize the options widget's values ***/
      options.set ({