Trigger an update/rerender-event from within Javascript? #7
-
Hi, first of all: The only thing I'm missing is the option to trigger a component-refresh with a javascript call. I'm searching for something like
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 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 And based on your above example, you could use the polling trigger to have the component automatically update itself periodically instead of doing it like that. For example |
Beta Was this translation helpful? Give feedback.
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 viaYoyoEngine
. You can trigger an event on a component usingYoyoEngine.trigger(elt, 'eventName', detail)
, documented here https://htmx.org/api/#triggerHowever, 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 theparameters
https://htmx.org/events/#htm…