 (event/listen! item-name-field :keypress #(on-enter % item-added))
 
 (defn add-item-to-list [item]
-  (d/append! items-list (render/shopping-list-item item)))
+  (d/append! items-list (render/shopping-list-item item))
+  (event/listen! (css/sel items-list "button") :click #(item-deleted %)))
+
+(defn remove-item-from-list [item]
+  ;; (:item item) is actually the delete button that was clicked
+  (d/detach! (-> item :item .-parentNode .-parentNode)))
 
 (defn focus-item-input [& args]
   (.focus item-name-field))

(pubsub/subscribe bus item-added focus-item-input)
(pubsub/subscribe bus item-added clear-item-input)


            [shoreleave.pubsubs.publishable :as pcore]
            [domina :as d]
            [domina.events :as event]
            [domina.css :as css]
            [eatme.client.render :as render])
  (:require-macros [shoreleave.remotes.macros :as srm]))

