# new RezBindingTransformer()
Transformer that creates two-way data bindings between form elements and game state.
Operates on form elements (input, select, textarea) with the rez-bind
attribute. The attribute value specifies the binding target in the format
element_id.attribute_name.
Special binding IDs:
game: Binds to the $game objectscene: Binds to the current scenecard: Binds to the nearest card in the DOM hierarchy
Supports input types: text, textarea, checkbox, radio, select.
Example
<!-- Bind to game.player_name -->
<input type="text" rez-bind="game.player_name">
<!-- Bind to current scene's difficulty -->
<select rez-bind="scene.difficulty">
Extends
Members
Methods
# decodeBinding(binding_expr) → {Array.<string>}
Parses a binding expression into element ID and attribute name.
Parameters:
| Name | Type | Description |
|---|---|---|
binding_expr |
string
|
Binding expression (e.g., "game.score") |
If binding expression is invalid
string
Array of [element_id, attribute_name]
Array.<string>
# getBoundElem(input, binding_id) → {Object}
Resolves a binding ID to its corresponding game element.
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Element
|
The form input element |
binding_id |
string
|
The binding target ID |
If card binding used outside a card context
Error
The resolved game element
Object
# getBoundValue(input, boundRezElementId, boundAttrName) → {*}
Gets the current value of a bound attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Element
|
The form input element |
boundRezElementId |
string
|
The binding target ID |
boundAttrName |
string
|
The attribute name |
If element not found
Error
The attribute value
*
# setBoundValue(input, boundRezElementId, boundAttrName, value)
Sets the value of a bound attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Element
|
The form input element |
boundRezElementId |
string
|
The binding target ID |
boundAttrName |
string
|
The attribute name |
value |
*
|
The new value |
If element not found
Error
# setRadioGroupValue(group_name, value)
Sets the selected radio button in a group.
Parameters:
| Name | Type | Description |
|---|---|---|
group_name |
string
|
The radio group name |
value |
string
|
The value to select |
# trackRadioGroupChange(group_name, callback)
Adds change tracking to all radios in a group.
Parameters:
| Name | Type | Description |
|---|---|---|
group_name |
string
|
The radio group name |
callback |
function
|
Callback for input events |
# transformCheckboxInput(view, input, binding_id, binding_attr)
Sets up two-way binding for a checkbox input.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
RezView
|
The view for binding registration |
input |
Element
|
The checkbox element |
binding_id |
string
|
The binding target ID |
binding_attr |
string
|
The attribute name |
# transformElement(input, view)
Transforms a form element by setting up two-way data binding.
Delegates to type-specific methods based on input type.
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Element
|
The form element to transform |
view |
RezView
|
The view for binding registration |
If input type is not supported
Error
# transformElements(view)
Transforms all matching elements in the document.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
RezView
|
The view being transformed |
- Inherited From:
# transformRadioInput(view, input, binding_id, binding_attr)
Sets up two-way binding for a radio button group.
Only the first radio in a group needs to register the binding.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
RezView
|
The view for binding registration |
input |
Element
|
A radio button in the group |
binding_id |
string
|
The binding target ID |
binding_attr |
string
|
The attribute name |
# transformSelect(view, select, binding_id, binding_attr)
Sets up two-way binding for a select element.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
RezView
|
The view for binding registration |
select |
Element
|
The select element |
binding_id |
string
|
The binding target ID |
binding_attr |
string
|
The attribute name |
# transformTextInput(view, input, binding_id, binding_attr)
Sets up two-way binding for a text input or textarea.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
RezView
|
The view for binding registration |
input |
Element
|
The input element |
binding_id |
string
|
The binding target ID |
binding_attr |
string
|
The attribute name |
# static constructor(receiver)
Creates a new RezBindingTransformer.
Parameters:
| Name | Type | Description |
|---|---|---|
receiver |
Object
|
Event receiver (unused, for API compatibility) |