Skip to content

Trigger an update/rerender-event from within Javascript? #7

Closed Answered by jreviews
cschilling asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks. Glad you are enjoying using Yoyo. Since at its core it uses https://htmx.org/ client-side for most Javascript stuff, you have access to the htmx JS API either directly using htmx or via YoyoEngine. You can trigger an event on a component using YoyoEngine.trigger(elt, 'eventName', detail), documented here https://htmx.org/api/#trigger

However, the detail object will not be posted with the request and this is an htmx limitation. One way to get around it would be to first add the data to some custom attribute of your choosing in the component element. Then add an event for htmx:configRequest where you read the attribute value and pass it to the parameters https://htmx.org/events/#htm…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cschilling
Comment options

Answer selected by jreviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants