behavior:select

Standard behavior of <select> lists. In principle it can be applied to any DOM element.

Elements

These elements have behavior:select applied by default:

Model

The <select> may contain <option> elements contained in arbitrary markup.

The behavior treats <option>'s or any other DOM element with attribute role="option" as a selectable entity.

Selected option will have :current  state flag set.

Examples, simple select:

<select>
  <option value="#ff0000" selected>Red</option>
  <option value="#00ff00">Green</option>
  <option value="#0000ff">Blue</option>
</select>

and <table> behaving as a select:

<style>
  table.select { behavior:select; }
  table.select > tr:current { color:white; background:blue; }
</style>

<table.select>
  <tr role=option value="#ff0000"><td>Red</td><td>#FF0000<td></tr>
  <tr role=option value="#00ff00"><td>Green</td><td>#00FF00<td></tr>
  <tr role=option value="#0000ff"><td>Blue</td><td>#0000FF<td></tr>
</table>

Attributes

This behavior knows about:

Events

Other than standard set of events (mouse, keyboard, focus) behavior:select generates:

Methods

N/A - behavior:select does not introduce any specific methods.

Commands

Note: commands are invoked by calling element.execCommand("cmd-name"[,params])

Properties

Other than standard properties of DOM elements the select also supports:

Value

any, read/write. value of selected option. Value of the option is its value attribute or option's text if there is no value defined.

Selection change handling in script

raw onValueChanged handler

var btn = $(select#some);
btn.onValueChanged = function() { var v = this.value; ... }

on() subscription

var btn = $(select#some);
btn.on("change", function() { ... event handling code ... });
self.on("change", "select#some", function() { ... event handling code ... });

decorators.tis handler

include "decorators.tis";
@change @on "select#some" :: ... event handling code ...;