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 1110

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

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 1153

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 1173

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 1198

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 1215

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 1280

# 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 1295

# 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 1264

# 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 1366

If input type is not supported

Error

# transformNumberInput(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 1335

# 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 1312

# 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 1245

# 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 1135