Created
January 22, 2022 02:34
-
-
Save ManickYoj/f4a710c1d831040747967500e1d35bd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/controllers/visibility_controller.js | |
import { Controller } from "@hotwired/stimulus" | |
export default class extends Controller { | |
static targets = [ "hideable" ] | |
showTargets() { | |
this.hideableTargets.forEach(el => { | |
el.hidden = false | |
}); | |
} | |
hideTargets() { | |
this.hideableTargets.forEach(el => { | |
el.hidden = true | |
}); | |
} | |
toggleTargets() { | |
this.hideableTargets.forEach((el) => { | |
el.hidden = !el.hidden | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment