Skip to content

Commit

Permalink
Touch up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpdoyle committed Apr 8, 2021
1 parent 770b2fd commit 21f2ca2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
13 changes: 8 additions & 5 deletions docs/reference/targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ Stimulus invokes each element callback any time its target elements are added or

```js
export default class extends Controller {
static targets = [ "input" ]
static targets = [ "item" ]

inputTargetConnected(element) {
element.classList.add("added-animation")
itemTargetConnected(element) {
this.sortElements(this.itemTargets)
}

inputTargetDisconnected(element) {
element.classList.add("removed-animation")
itemTargetDisconnected(element) {
this.sortElements(this.itemTargets)
}

// Private
sortElements(itemTargets) { /* ... */ }
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/@stimulus/core/src/target_properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ function propertiesForTargetDefinition(name: string) {
get(this: Controller) {
return this.targets.has(name)
}
},
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export default class extends Controller {
}
}

itemTargetAdded(target) {
console.log("itemTargetAdded:", target)
itemTargetConnected(target) {
console.log("itemTargetConnected:", target)
}

itemTargetRemoved(target) {
console.log("itemTargetRemoved:", target)
itemTargetDisconnected(target) {
console.log("itemTargetDisconnected:", target)
}

disconnect() {
Expand Down

0 comments on commit 21f2ca2

Please sign in to comment.