 (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))

  
(def item-added (pubsub/publishize (fn [e] {:item-name (d/value item-name-field)}) bus))

(defn on-enter [e f]
  (when (= 13 (:keyCode e)) (item-added e)))


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

(pubsub/subscribe bus item-deleted log-to-console)
(pubsub/subscribe bus item-deleted remove-item-from-list)

(focus-item-input)