Skip to content

Commit 71e3b69

Browse files
committed
Add search method to form controller
1 parent 0043202 commit 71e3b69

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [Unreleased]
22
- Make .field_with_errors become pseudo-box by default.
3+
- Add search method to form controller
34

45
## 1.1.0 - 2025-02-15
56
- Improve command with first option select

lib/generators/css_zero/add/templates/app/javascript/controllers/form_controller.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import { Controller } from "@hotwired/stimulus"
2+
import debounce from "https://esm.sh/[email protected]?standalone"
23

34
export default class extends Controller {
45
static targets = [ "cancel" ]
56

7+
initialize() {
8+
this.search = debounce(this.search.bind(this), 500)
9+
}
10+
611
submit() {
712
this.element.requestSubmit()
813
}
914

15+
search() {
16+
this.element.requestSubmit()
17+
}
18+
1019
cancel() {
1120
this.cancelTarget?.click()
1221
}

0 commit comments

Comments
 (0)