Previews

Pages

No matching results.

x
1
<input type="text" name="autoselect" id="autoselect" value="change me" class="input" autofocus="autofocus" data-controller="autoselect" />
1
<%= text_field_tag "autoselect", "change me", class: "input", autofocus: true, data: { controller: "autoselect" } %>
CSS is not required or multiple files are needed, check the notes.
1
2
3
4
5
6
7
8
9
10
11
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
this.autoselect && this.element.select()
}
get autoselect() {
return this.element.autofocus
}
}