I've got an index page with a search which mostly works, aside from when there are no results, which is when I get the error:-
response has no matching <turbo-frame id="events"> element
I don't get this when there are search results. Do I need to specify a partial to render in my index action, when results are empty? Why isn't this being evaluated in my view?
index.html.erb
<div id="events-wrapper">
<% if @events.any? %>
<%= render "events", events: @events %>
<% else %>
<%= render "no_events" %>
<% end %>
</div>
_events.html.erb
<%= turbo_frame_tag "events" do %>
<%= render collection: @events, partial: 'event' %>
<%= raw pagy_bootstrap_nav(@pagy) %>
<% end %>
_no_events.html.erb
<div class="no-events-notice alert alert-primary">
No events found
</div>
events_controller.rb index action
def index
@pagy, @events = pagy(find_events(filter_params))
end
Basically my search works fine, but when there are no results - my no_events
partial doesn't get rendered, unless I refresh the page. What am I missing?
I've removed the partial from the equation and just replaced that line with a simple div instead and it's still not displayed.