Hotwire Discussion

Running js after a broadcast

how can i run js after i broadcast a frame?
i have a page that if the player is deleted from the game it would redirect him/her out with a message

If you’re using Stimulus, you could add the JavaScript inside the connect method of your controller, which will run as soon as the controller is added to the DOM.

// the partial that is broadcasted
<turbo-frame id="my-frame-id">
  <div data-controller="delete-player">
// delete_player_controller.js
import { Controller } from "stimulus"

export default class ApplicationController extends Controller {
  connect() {