Class RapidContext.Widget.TextField

Extends: RapidContext.Widget

The text field widget class. Used to provide a text input field for a single line, using the <input> HTML element. The text field may also be connected to a popup (for auto-complete or similar).

Source code: RapidContext_Widget_TextField.js

Class Summary
 
Creates a new text field widget.
Field Summary
 
The value to use on form reset.
 
The read-only widget disabled flag.
 
The read-only widget focused flag.
Method Summary
 
Returns the text field value.
 
popup(create)
Returns (or creates) a popup for this text field.
 
Resets the text area form value to the initial value.
 
setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
 
showPopup(attrs, items)
Shows a popup for the text field containing the specified items.
Methods borrowed from class RapidContext.Widget:
addAll, addChildNode, addClass, animate, blurAll, destroy, disable, enable, getChildNodes, hasClass, hide, isDisabled, isHidden, removeAll, removeChildNode, removeClass, setStyle, show, toggleClass, uid
Event Summary
 
Emitted when the text is modified.
 
Emitted when an item has been selected in the connected popup.
Class Detail
RapidContext.Widget.TextField(attrs)
Creates a new text field widget.
JavaScript:
var attrs = { name: "name", helpText: "Your Name Here" };
var field = RapidContext.Widget.TextField(attrs);
User Interface XML:
<TextField name="name" helpText="Your Name Here" />
Parameters:
{Object} attrs
the widget and node attributes
{String} attrs.name Optional
the form field name
{String} attrs.value Optional
the field value, defaults to ""
{String} attrs.helpText Optional
the help text shown on empty input, defaults to ""
{Boolean} attrs.disabled Optional
the disabled widget flag, defaults to false
{Boolean} attrs.hidden Optional
the hidden widget flag, defaults to false
{Object} ... Optional
the initial text content
Returns:
{Widget} the widget DOM node
Field Detail
{Boolean} disabled
The read-only widget disabled flag.

{Boolean} focused
The read-only widget focused flag.

{String} defaultValue
The value to use on form reset.
Method Detail
setAttrs(attrs)
Updates the widget or HTML DOM node attributes.
Parameters:
{Object} attrs
the widget and node attributes to set
{String} attrs.name Optional
the form field name
{String} attrs.value Optional
the field value
{String} attrs.helpText Optional
the help text shown on empty input
{Boolean} attrs.disabled Optional
the disabled widget flag
{Boolean} attrs.hidden Optional
the hidden widget flag

reset()
Resets the text area form value to the initial value.

{String} getValue()
Returns the text field value. This function is slightly different from using the value property directly, since it will always return the actual value string instead of the temporary help text displayed when the text field is empty and unfocused.
var value = field.getValue();
value = MochiKit.Format.strip(value);
field.setAttrs({ "value": value });
Returns:
{String} the field value

Returns (or creates) a popup for this text field. The popup will not be shown by this method, only returned as-is. If the create flag is specified, a new popup will be created if none has been created previously.
Parameters:
{Boolean} create
the create popup flag
Returns:
{Widget} the popup widget, or null if none existed or was created

showPopup(attrs, items)
Shows a popup for the text field containing the specified items. The items specified may be either a list of HTML DOM nodes or text strings.
var items = ["Cat", "Dog", "Elephant", "Zebra"];
field.showPopup({}, items);
Parameters:
{Object} attrs Optional
the popup attributes to set
{Number} attrs.delay Optional
the popup auto-hide delay, defaults to 30 seconds
{Array} items Optional
the items to show, or null to keep the previous popup content
Event Detail
onchange()
Emitted when the text is modified. This event is triggered by either user events (keypress, paste, cut, blur) or by setting the value via setAttrs(). The DOM standard onchange event has no event.detail data and is triggered on blur. The synthetic onchange events all contain an event.detail object with before, after and cause properties.

ondataavailable()
Emitted when an item has been selected in the connected popup. This event signal carries no event.detail information.