Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate using {{on}} with <Input ... />. #19314

Merged
merged 7 commits into from
Jan 15, 2021
15 changes: 15 additions & 0 deletions packages/@ember/-internals/glimmer/lib/components/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ import InternalComponent from './internal';
<Input @value={{this.searchWord}} @enter={{this.query}} />
```

Starting with Ember Octane, we recommend using the {{on}} modifier to call actions
romance939913 marked this conversation as resolved.
Show resolved Hide resolved
on specific events, such as the input event.

```
romance939913 marked this conversation as resolved.
Show resolved Hide resolved
<label for="input-name">Name:</label>
<Input
@id="input-name"
@value={{this.name}}
{{on "input" this.validateName}}
/>
romance939913 marked this conversation as resolved.
Show resolved Hide resolved
```

The event name (e.g. "focusout", "input", "keydown") always follows the casing
romance939913 marked this conversation as resolved.
Show resolved Hide resolved
that the HTML standard uses.

### `<input>` HTML Attributes to Avoid

In most cases, if you want to pass an attribute to the underlying HTML `<input>` element, you
Expand Down