Class

RezBindingTransformer

RezBindingTransformer()

Constructor

# 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 object
  • scene: Binds to the current scene
  • card: Binds to the nearest card in the DOM hierarchy

Supports input types: text, textarea, checkbox, radio, select.

View Source rez_view.js, line 1105

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

NodeList

# elements

All DOM elements matching this transformer's selector.

Inherited From:

View Source rez_view.js, line 827

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")

View Source rez_view.js, line 1148

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

View Source rez_view.js, line 1168

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

View Source rez_view.js, line 1193

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

View Source rez_view.js, line 1210

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

View Source rez_view.js, line 1275

# 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

View Source rez_view.js, line 1290

# 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

View Source rez_view.js, line 1259

# 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

Overrides:

View Source rez_view.js, line 1349

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:

View Source rez_view.js, line 836

# 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

View Source rez_view.js, line 1307

# 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

View Source rez_view.js, line 1330

# 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

View Source rez_view.js, line 1240

# static constructor(receiver)

Creates a new RezBindingTransformer.

Parameters:
Name Type Description
receiver Object

Event receiver (unused, for API compatibility)

View Source rez_view.js, line 1130