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

"Before Cache" / "Event" feature #18

Open
snellingio opened this issue Sep 3, 2019 · 2 comments
Open

"Before Cache" / "Event" feature #18

snellingio opened this issue Sep 3, 2019 · 2 comments

Comments

@snellingio
Copy link

I'd like to create a dropdown with the Toggle feature. However, the toggle will remain open on hitting the back button with Turbolinks. Using stimulus and turbolinks, I'd normally either remove the node or add / remove a class.

Maybe there is room for a before cache feature? Or alternatively, maybe an event feature might keep it more flexible?

@snellingio
Copy link
Author

The more I think about it, maybe we should have an event option on most of the features.

That way, I can write a javascript "plugin" more or less that will fire the events to control the page.

My usecase is hooking up certain events with laravel's echo websocket server. I'd like to refresh an element or something similar by firing an event.

Definitely needed with the replace function, but I'll keep searching the codebase to see if there is anything else using a similar architecture.

@johnholdun
Copy link
Contributor

Can you solve this problem by using <details> instead of toggle? Alternatively, you could write some Javascript that listens for turbolinks:load and toggles your element by sending a click event. I do something very similar to this on the Trimmings docs, in fact; check out adjustNav in the source.

Trimmings strives to augment existing DOM APIs, so in essence it already does have an event option. Since most Trimmings feature are listening for clicks and submits, you can send a click or submit event to a Trimmings-bound element yourself based on whatever logic you may need for your particular use case.

I think this answers your question, but let me know if I've missed the point here. Thanks!

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

2 participants