Javascript integration with phoenix live view

I’m developing a live view app that has steps in one page and according to any steps, it has some html elements added or removed. since when it goes to each step condition the javascript tags won’t run I need to handle it with events.

Is there any solution that for each step from phoenix I trigger a javascript event or something?
the final thing is when any step loads I want a javascript to be triggers with step name or some data to be used in next step.

any help would be appreciated

Have you read here?

1 Like

Given the html below:

<div id="step_hook" phx-hook="StepHook" data-step="<%= @step_number %>">

each time you update @step_number assign, StepHook.updated() callback will be called:

updated() {
  console.log("Hi from step number:", this.el.dataset.step)