1

I am using Flowbite dropdown component with flowbite.turbo.js. The problem is that after the frame is rendered, Flowbite is not reloaded and the dropdown do not open.

How can I re-initiliaze Flowbite components after the turbo:frame-load event?

application.js

import 'flowbite';
import "flowbite/dist/flowbite.turbo.js";

index.html.erb

 <%=turbo_frame_tag "example" do %>
      <!--  DROPDOWN FLOWBITE THAT DO NOT OPENS -->


<button id="dropdownDefaultButton" data-dropdown-toggle="dropdown" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" type="button">Dropdown button <svg class="w-4 h-4 ml-2" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></button>
<!-- Dropdown menu -->
<div id="dropdown" class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700">
    <ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton">
      <li>
        <a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Dashboard</a>
      </li>
    </ul>
</div>


<% end %>

example.html.erb

<%=turbo_frame_tag "example", src: url_for(action: :example), loading: 'lazy' do %>
      Loading...
<% end %>
sparkle
  • 7,530
  • 22
  • 69
  • 131

0 Answers0