Skip to content
Permalink
Browse files

marking items as done

  • Loading branch information...
dnsbty committed Apr 13, 2019
1 parent 48c5dfe commit f13ba37393bec7f8c3aa8f40ad5a690922068581
@@ -20,6 +20,12 @@ defmodule LiveViewTodosWeb.TodoLive do
{:noreply, fetch(socket)}
end

def handle_event("toggle_done", id, socket) do
todo = Todos.get_todo!(id)
Todos.update_todo(todo, %{done: !todo.done})
{:noreply, fetch(socket)}
end

def handle_info({Todos, [:todo | _], _}, socket) do
{:noreply, fetch(socket)}
end
@@ -4,5 +4,8 @@
</form>

<%= for todo <- @todos do %>
<div><%= todo.title %></div>
<div>
<%= checkbox(:todo, :done, phx_click: "toggle_done", phx_value: todo.id, value: todo.done) %>
<%= todo.title %>
</div>
<% end %>

0 comments on commit f13ba37

Please sign in to comment.
You can’t perform that action at this time.