Hotwire Discussion

Turbo:render and turbo:load event is not fired at link_to with data-turbo-method

I got a hint from Destroy record in turbo-frame so am using link_to with data-turbo-method like this. when I click the a tag, modifed icon is rendered well. bootstrap tooltip is hided well, but it is not reinitiated for change icon.

<%= turbo_frame_tag("idea_favorite", data: { turbo: true , controller: "custom-handler", action: 'turbo:submit-end->custom-handler#hideTooltip turbo:load->custom-handler#reInitTooltip'}) do %>
  <%=link_to toggle_favorite_idea_path(@idea), class: 'favorite', data: {turbo_method: :patch, bs_toggle: "tooltip", bs_placement: "top"}, title: 'are you sure?' do %>
    <i class="far fa-star"></i>
  <% end %>
<% end %>

rails controller code is just rendering change icon and tooltip.
I want to re-initialize tooltip again.

This is stimulus code.

import { Controller } from "stimulus"

export default class extends Controller {

  connect() {
     console.log("connected!!", this.element)
  }

  hideTooltip(event) {
      $(".tooltip").tooltip("hide")
      console.log("hideTooltip")
    }

    reInitTooltip(event) {
      console.log("reInitTooltip")
      $('[data-bs-toggle="tooltip"]').tooltip()
    }
}

When I click the link button, hideTooltip function is working but reInitTooltip function is not called. I have tried with turbo:render but that event is not fired either.

I tried to got event at connect function but stimulus connect function is not called after clicked and rendered server code. ( I understand that connect method is called whenever the reloaded turbo-frame is connected with stimulus controller )

Why the turbo:load event is not fired?