Event Hook Attributes
Event hook attributes enable and configure backend handlers for DOM events. Each attribute is a struct rendered before or spread onto an element to bind a typed On handler and optional client-side behavior.
Common Options
Most event hook attributes share these fields:
StopPropagation· stop event bubbling.PreventDefault· prevent the browser default.ExactTarget· fire only on the element itself.Scope []Scope· control scheduling (blocking, debounce, etc.).Indicator []Indicator· UI indication while running.Before []Action· actions before request.OnError []Action· actions on error.On func(context.Context, REvent[T]) bool· backend handler, returntrueto complete and remove the hook. TypeTdepends on the event.
Render inline:
@doors.AClick{
PreventDefault: true,
On: func(ctx context.Context, ev doors.REvent[doors.PointerEvent]) bool {
/* logic */
return false
},
}
<button>Click</button>
Or spread:
{{ click := doors.AClick{ On: func(ctx context.Context, ev doors.REvent[doors.PointerEvent]) bool { return true } } }}
<button { doors.A(ctx, click)... }>Click</button>
Available Attributes
Pointer events
AClickAPointerDown,APointerUp,APointerMoveAPointerOver,APointerOut,APointerEnter,APointerLeaveAPointerCancelAGotPointerCapture,ALostPointerCapture
All use REvent[PointerEvent]. Support propagation and default control.
Focus events
AFocus,ABlur
UseREvent[FocusEvent]. Basic capture.AFocusIn,AFocusOut
SupportStopPropagationandExactTarget.
Keyboard events
AKeyDown,AKeyUp
UseREvent[KeyboardEvent]. SupportFilter []stringonevent.key, plus propagation/default options.
Input and change
AInput·REvent[InputEvent]with optionalExcludeValue.AChange·REvent[ChangeEvent]for committed value changes.
Forms
ASubmit[T]· multipart parsing and decoding intoT(via go-playground/form v4). OptionalMaxMemory. Handler getsRForm[T].ARawSubmit· raw multipart access for streaming/uploads. Handler getsRRawForm.
Concurrency
Within a single hook, backend On calls are serialized. Multiple events on the same handler queue on the backend. Reusing a pre-initialized attribute across elements joins their queue.
@doors.ASubmit[Data]{
On: func(ctx context.Context, r doors.RForm[Data]) bool {
/* safe, next call runs after this returns */
return false
},
}
<form>...</form>
Scopes
Use scopes for precise scheduling, such as debounce and blocking.
@doors.AInput{
Scope: doors.ScopeOnlyDebounce(300 * time.Millisecond, time.Second),
On: func(ctx context.Context, r doors.REvent[doors.InputEvent]) bool { return false },
}
See Scopes for details.
Indicators
Apply pending indication with the Indicator API.
@doors.ASubmit[loginData]{
Indicator: doors.IndicatorOnlyAttrQuery("#login-submit", "aria-busy", "true"),
Scope: doors.ScopeOnlyBlocking(),
On: func(ctx context.Context, r doors.RForm[loginData]) bool { return true },
}
See Indication for details.
Errors
OnError runs when a hook processing error occurs. It supports UI indication, navigation, and custom JS actions. See Actions and JavaScript for error object details.