Thursday, June 04, 2026 2:15:00 AM
> turbo_helper.rb
# frozen_string_literal: true

module TurboHelper
  def turbo_frame(id, **args, &block)
    turbo_frame_tag("#{id}_frame", **args, &block)
  end

  alias_method :update_turbo_frame, :turbo_frame

  def update_turbo_modal(id, &block)
    turbo_frame_tag("#{id}_frame") do
      yield

      concat content_tag(:div, nil, data: {trigger: "modal:show:##{id}"})
    end
  end

  def show_modal(selector)
    turbo_stream.append("main-container") do
      content_tag(:div, nil, data: {trigger: "modal:show:#{selector}"})
    end
  end

  def hide_modal(selector)
    turbo_stream.append("main-container") do
      content_tag(:div, nil, data: {trigger: "modal:hide:#{selector}"})
    end
  end
end
All opinions represented herein are my own
- © 2024 - 2026 itsthedevman
- build 4294fb2