Liveview: navigate with phx-click

The way that events work is like this: you have phx-click="name_of_event". Then, in your module, you define an event handler like this:

def handle_event("name_of_event", _, socket) do
     all the stuff you want
end

handle_event pattern matches on events, and the string for the first arg will match against the string you defined in phx-click. You don’t define a function called name_of_event. Rather, you define a handle_event clause that pattern matches on the name.