Hey guys I begin with phoenix LiveView so I wanna try something but it doesn’t work.
There is my code in page live:
def mount(_params, %{}, socket) do
categories = CatRequette.get_all_categorie()
{:ok, socket |> assign(categories: categories, panier: 0, search: nil)}
end
def handle_event("add", %{}, socket) do
{:noreply, update(socket, :panier, &plus/1)}
end
defp plus(x) do
x + 1
end
def render(assigns) do
BebemayotteWeb.PageView.render("contact.html", assigns)
end
The code you have looks largely correct actually, I think @sebb is wrong, update is also valid. However, are you sure your handle_event clause is firing?