Advertisement
Guest User

Untitled

a guest
Apr 25th, 2020
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (def columns
  2.   [{:title "Name"
  3.     :data "name"}
  4.    {:title "Age"
  5.     :data "age"}])
  6.  
  7. (def data
  8.   [{"name" "Matthew"
  9.     "age" "26"}
  10.    {"name" "Anna"
  11.     "age" "24"}
  12.    {"name" "Michelle"
  13.     "age" "42"}
  14.    {"name" "Frank"
  15.     "age" "46"}])
  16.  
  17. (defn home-render []
  18.   [:div
  19.    [:table.ui.celled.table
  20.     {:ref "main" :width "100%"}]])
  21.  
  22. (defn home-did-mount [this]
  23.   (.DataTable
  24.    (-> this .-refs .-main js/$)
  25.    (clj->js
  26.     {:columns columns
  27.      :data data
  28.      :responsive true})))
  29.  
  30. (defn home-will-unmount [this]
  31.   (.destroy
  32.    (.DataTable
  33.     (.find
  34.      (js/$ ".dataTables_wrapper")
  35.      "table"))
  36.    true))
  37.  
  38. (defn home []
  39.   (r/create-class
  40.    {:reagent-render home-render
  41.     :component-did-mount home-did-mount
  42.     :component-will-unmount home-will-unmount
  43.     :should-component-update (fn [& args] false)}))
Advertisement
RAW Paste Data Copied
Advertisement