Behavior of hierarchical <select> lists. It can be applied to any block level container.
These elements have behavior:select applied by default:
<select|tree></select>
The behavior recoginizes two types <option>s:
<option> <caption>Node caption</caption> <option>Leaf 1</option> <option>Leaf 2</option> </option>
Selected option will have :current
state flag set.
Node <option> gets :node
runtime flag set (and corresponding CSS pseudo-class) on it by the runtime. Therefore selectors:
option:node
- match all node options;option:not(:node)
- match all leaf nodes.option:node
may have either :expanded
or :collapsed
runtime flag set in response to UI events (mouse and keyboard events).
The behavior supports so called "virtual tree" mode. Initially the tree may have all node options collapsed and empty and populate them upon ELEMENT_EXPANDED event receiving. And clear on ELEMENT_COLLAPSED event to minimize memory needed to represent the tree. See sdk/samples/ideas/virtual-tree/ sample.
expanded
on <option> - <option expanded> will get :expanded
state by default.Other than standard set of events (mouse, keyboard, focus) behavior:tree-view generates:
N/A - behavior:tree-view does not introduce any specific methods.
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.
onControlEvent
handlervar btn = $(select#some); btn.onControlEvent = function(evt) { switch(evt.type) { case Event.SELECT_SELECTION_CHANGED: /* current option was changed */ break; case Event.ELEMENT_EXPANDED: /* evt.target is expanded */ break; case Event.ELEMENT_COLLAPSED: /* evt.target is collapsed */ break;
} }
on()
subscriptionvar sel = $(select#some); sel.on("change", function() { ... event handling code ... }); sel.on("expand", "option", function() { ... event handling code ... }); sel.on("collapse", "option", function() { ... event handling code ... });
include "decorators.tis"; @when Event.ELEMENT_EXPANDED @on "select#some" :: ... event handling code ...; @when Event.ELEMENT_COLLAPSED @on "select#some" :: ... event handling code ...;