Opening Liveview Window phx-click

Currently I need to open a window by clicking the button using phx-click.
The idea would be like the new(Default) button.

What is the correct way to do this?

I currently have this.
Ex:
index.ex

   @impl true
   def handle_event("export", _, socket) do
     {:noreply, socket}
   end

index.html.ex
<button class="dropdown-item" phx-click="import">Import</button>

Can you clarify what you mean by this? Do you want to open a modal on top of the current page? Do you want to have a link that opens a new browser tab / window?

That would be a modal.

I just found something that might help me.

Try to create a new project, then a live resource…

$ mix phx.new koko
$ cd koko
$ mix ecto.reset
$ mix phx.gen.live ...

You will get sample code for modal usage.

1 Like