Skip to content

Instantly share code, notes, and snippets.

@bschrag620
bschrag620 / _trigger.html.erb
Created February 28, 2024 13:22
Stimulus Page Refreshing
<%# Create a partial for generating a trigger element to be appended to the container in a turbo_stream %>
<% selectors ||= '' %>
<%
# As a convenience, we can use Array.wrap to turn the selector value into an array if it is not one, then use join(' ') to
# create a list that works nicely with the stimulus controller.
%>
<div data-refresh-target='trigger' data-selctors='<%= Array.wrap(selectors).join(" ") %>'