Last active
December 11, 2015 16:34
-
-
Save joelkuiper/0b970745cda78de007a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn selectize | |
[options settings] | |
(let [id | |
(util/rand-uuid) | |
get-selectize | |
(fn [] (.-selectize (aget (js/$ (str "#" id)) 0))) | |
selectize! | |
(fn [this] | |
(let [[_ options _ _ ] (reagent/argv this)] | |
(.selectize | |
(js/$ (str "#" id)) | |
(clj->js (assoc settings :options (vec (:options options))))) | |
(.setValue (get-selectize) (clj->js (:defaults options)))))] | |
(reagent/create-class | |
{:component-did-mount selectize! | |
:component-will-unmount #(.destroy (get-selectize)) | |
:render (fn [] [:input {:id id}])}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[selectize | |
{:defaults [] | |
:options []} ;; options and default selected | |
{:plugins ["remove_button"] ;; all other selectize settings | |
:onChange update!} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment