On load#
Demo#
No session data
Explanation#
<div id="replaceMe" data-on-load="sse('/examples/on_load/data', {method:'post'})">
No session data
</div>
The data-on-load
attribute is used to specify a fetch request that should be made when the element is loaded. The value of the attribute is a JavaScript expression that is evaluated when the element is loaded. This example comes from a GitHub issue where the user wanted to load session data when the page was loaded.
Note: In this case its targeting the #replaceMe
element but its up to the SSE returned to how the page is updated.