Hello,
I am following this tutorial todo list, one of the last challenges is to create a delete button by yourself. I attempted to replicate it using the update_todo and doing the opposite. However, the button does not delete the to-do created.
my func below to delete
def handle_event("toggle_delete", %{"id" => id}, socket)do
todo = Todos.get_todo!(id)
Todos.delete_todo(todo, %{delete: todo.id})
{:noreply, socket}
end
&
The button I created below
<form action ="#" phx-submit="add">
<%= text_input :todo, :title, placeholder: "What do you want to get done" %>
<%= submit "Add", phx_disable_with: "Adding..." %>
</form>
<%= for todo <- @todos do %>
<div>
<%= checkbox(:todo, :done, phx_click: "toggle_done", phx_value_id: todo.id, value: todo.done) %>
**<button phx_click="toggle_delete", :delete, phx_value_id: todo.id, value: todo.delete> Delete</button>**
<%= todo.title %></div>
<% end %>
What am I doing wrong?