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

Programmatic Toggling #116

Open
markjohnson4 opened this issue Nov 3, 2021 · 5 comments
Open

Programmatic Toggling #116

markjohnson4 opened this issue Nov 3, 2021 · 5 comments

Comments

@markjohnson4
Copy link

markjohnson4 commented Nov 3, 2021

Is it possible to trigger a method that toggles an element so I can toggle it via some custom javascript logic?

Some context: I have a table with a button in a tr element that, when clicked, displays "child" tr elements (from the DOM's perspective, though, these tr elements are sibling elements). each of those child tr elements also has a button that displays their own "child" elements. If I toggle the top-level tr button to hide its children, I want to also hide its grandchildren. Does that make sense?

@Twikito
Copy link
Owner

Twikito commented Nov 10, 2021

Hi @markjohnson4!

Quite hard to understand. Do you have any screenshot?

@markjohnson4
Copy link
Author

Hi! Sorry, my "some context" is too confusing. I think it's simpler to simpler to illustrate what I want with this:

if(condition) {
toggleOn(element);
}
else {
toggleOff(element);
}

are there functions like this that can "toggleOn" or "toggleOff"?

thanks!

@Twikito
Copy link
Owner

Twikito commented Dec 2, 2021

Hi!

Maybe you could find a solution using the hooks? https://twikito.github.io/easy-toggle-state/#hooks

@markjohnson4
Copy link
Author

Hi! I mean a method to trigger a toggle state. Like bootstrap modals can be opened with the JavaScript: myModalElement.modal('show'). Is there something like myToggleElement.toggle('show")?

here's the bootstrap modal example I'm talking about: https://getbootstrap.com/docs/4.0/components/modal/#modalshow

thanks!

@henrijs
Copy link

henrijs commented Dec 4, 2023

if (isActive(button)) { button.click() }

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

3 participants