@@ -8,5 +8,32 @@ import { Controller } from '@hotwired/stimulus';
88/* stimulusFetch: 'lazy' */
99export default class extends Controller {
1010 static targets = [ 'results' , 'messages' , 'errors' ]
11- // ...
11+
12+ initialize ( ) {
13+ // Called once when the controller is first instantiated (per element)
14+
15+ // Here you can initialize variables, create scoped callables for event
16+ // listeners, instantiate external libraries, etc.
17+ // this._fooBar = this.fooBar.bind(this)
18+ }
19+
20+ connect ( ) {
21+ // Called every time the controller is connected to the DOM
22+ // (on page load, when it's added to the DOM, moved in the DOM, etc.)
23+
24+ // Here you can add event listeners on the element or target elements,
25+ // add or remove classes, attributes, dispatch custom events, etc.
26+ // this.fooTarget.addEventListener('click', this._fooBar)
27+ }
28+
29+ // Add custom controller actions here
30+ // fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
31+
32+ disconnect ( ) {
33+ // Called anytime its element is disconnected from the DOM
34+ // (on page change, when it's removed from or moved in the DOM, etc.)
35+
36+ // Here you should remove all event listeners added in "connect()"
37+ // this.fooTarget.removeEventListener('click', this._fooBar)
38+ }
1239}
0 commit comments