Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to utlize cb? #181

Closed
bilogic opened this issue Mar 26, 2023 · 0 comments
Closed

How to utlize cb? #181

bilogic opened this issue Mar 26, 2023 · 0 comments

Comments

@bilogic
Copy link

bilogic commented Mar 26, 2023

_hide(cb) {
setTimeout(
(() => {
if (this.hasButtonTarget) {
this.buttonTarget.setAttribute("aria-expanded", "false")
}
this._invisibleClassList[0].forEach(klass => this.menuTarget.classList.add(klass))
this._visibleClassList[0].forEach(klass => this.menuTarget.classList.remove(klass))
this._activeClassList[0].forEach(klass => this.activeTarget.classList.remove(klass))
this._leavingClassList[0].forEach(klass => this.menuTarget.classList.add(klass))
setTimeout(
(() => {
this._leavingClassList[0].forEach(klass => this.menuTarget.classList.remove(klass))
if (typeof cb == 'function') cb()

I noticed this cb in the controllers, does it mean there is a way to pass a callback into the controllers?
My use case is, I would like to have a toggle switch to change some setting on the server, but I don't want to be hardcoding the XHR/AJAX inside the controller itself.

Any examples of how I can do this callback from controller back to the HTML side?

Thank you.

UPDATE: ok, I misunderstood the code

@bilogic bilogic closed this as completed Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant