Opening Modal window on span click

Hi ,
I need help in opening a modal on click of span.
I am not even able to trigger phx-click function on click of span:

Following is the code:
span phx-click=“shareit” style=“float:right”

Can you please show the code that isn’t working?

something like this in span tag
phx-click=“shareit” style=“float:right”
then defining the event like this:
def handle_event(“shareit”,socket) do
IO.puts “Hello World”


Do you see any javascript errors in the console? Can you show logs from your phoenix server? In general by the way when folks ask for code they want your actual code, not merely a summary. The details matter.

1 Like

You have one parameter missing from handle_event.

Try this
def handle_event(“shareit”, _value, socket) do
IO.puts “Hello World”

Also note that phx-click events would only work with buttons on iOS devices. So I recommend using buttons instead of the span.

In our experience <a href></a> also works too.

1 Like