0

我正在向我的app-db添加一个搜索 id 元素:

[:input {:type "checkbox" :on-change #(reframe/dispatch [:add-elm {:subject_id subject-id}])}]

但我不知道如何识别最终用户何时选中或取消选中该框以便从 app-db 放置或取出元素。我想避免在 app-db 中搜索以查看该元素是否已经存在。

4

1 回答 1

0

1)在复选框中添加一个ID:

   [:input {:type "checkbox" :title (:subject row-subject) 
          :id (str "subjects_" (:id row-subject))
          :on-change #(rf/dispatch [:add-search-elm {"subjects" (:id row-subject)}])}]   

2) 获取并读取 DOM 元素:

 (let [ksection  (first (first updates))  ;; key subject
      vsection  (get updates ksection)   ;; value subject
      elm       (str ksection "_" vsection)
      checkbox  (gdom/getElement elm)
      checked   (.. checkbox -checked)]
     (.log js/console (str ">>> ksection >>>>> " ksection  ";;  vsection >> " vsection  ";;  elm >> " elm "   checkbox >>> " checkbox ";; checked >> " checked))
于 2020-04-21T18:51:34.173 回答