Class JsTrigger
java.lang.Object
com.vaadin.flow.component.trigger.AbstractTrigger
com.vaadin.flow.component.trigger.JsTrigger
- All Implemented Interfaces:
Trigger,Serializable
Trigger backed by an arbitrary JavaScript expression — the escape hatch for
cases not covered by a built-in
AbstractTrigger.
The expression is evaluated once during bind with the host element as
this and a single named parameter trigger — a function the
expression must call (synchronously, inside a DOM event handler) to fire the
trigger. The expression may return a cleanup function; if it does, the
cleanup runs when the trigger is removed or when the host is re-bound.
new JsTrigger(host, "this.addEventListener('dblclick', trigger);"
+ "return () => this.removeEventListener('dblclick', trigger);")
.triggers(action);
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodebuildClientConfig(ConfigContext context) Produces the JSON configuration this trigger sends to the client.Methods inherited from class com.vaadin.flow.component.trigger.AbstractTrigger
getHost, getTriggerId, getTypeId, remove, triggers, triggers
-
Field Details
-
TYPE_ID
- See Also:
-
-
Constructor Details
-
JsTrigger
Creates a JS-backed trigger on the given host element.- Parameters:
host- the host element, notnullexpression- the JS source, notnull
-
JsTrigger
Creates a JS-backed trigger on the given component's root element.- Parameters:
host- the host component, notnullexpression- the JS source, notnull
-
-
Method Details
-
getExpression
- Returns:
- the JS expression
-
buildClientConfig
Description copied from class:AbstractTriggerProduces the JSON configuration this trigger sends to the client. Default is an empty object; override to add type-specific options.The
contextlets subclasses encode element/output references by id when needed. Public so the internal framework can read the config without reflection; subclasses just override.- Overrides:
buildClientConfigin classAbstractTrigger- Parameters:
context- the resolver for referenced elements and outputs, notnull- Returns:
- a Jackson
ObjectNode, nevernull
-