I've noticed this strange behavior of turbo frames loading lazily via src
attribute setting:
nav
= turbo_frame_tag 'primary_menu', src: primary_menu_path
: def primary_menu
: respond_to do |format|
: format.turbo_stream
> : format.html { binding.pry ; render plain: 'should not reach this block' }
: end
: end
)> turbo_frame_request?
=> true
For some reason, it is interpreted as regular requested html request, although
turbo_frame_request?
returns => true
. What's causing it and how to fix it?
P.S. primary_menu.turbo_stream.slim
exists for that controller action.
Local versions:
hotwire-rails 0.1.3
@hotwired/turbo-rails 7.0.0-beta.5
Before someone with better knowledge of
turbo
internals explains it properly, below is a method that worked for me:Would be interpreted as HTML request:
in your
primary_menu.html.erb
make sure you wrap your content with<%= turbo_frame_tag 'primary_menu' do %>
block.Keep in mind that:
turbo_frame_tag
names have to match here and its original definition/require.turbo_frame_tag
wrapped blocks in that response would be silently ignored.