fixes
This commit is contained in:
@@ -32,45 +32,8 @@
|
||||
(:allow-blank? params) (conj [:option {:value "" :selected (not (:value params))} ""]))]
|
||||
children))
|
||||
|
||||
|
||||
(defn typeahead- [params]
|
||||
[:select (-> params
|
||||
(dissoc :url)
|
||||
(dissoc :value)
|
||||
(dissoc :value-fn)
|
||||
(dissoc :content-fn))
|
||||
(for [value (if (:multiple params)
|
||||
(:value params)
|
||||
[(:value params)])
|
||||
:when ((:value-fn params first) value)]
|
||||
[:option {:value ((:value-fn params first) value) :selected true} ((:content-fn params second) value)])
|
||||
|
||||
[:script {:lang "javascript"}
|
||||
(hiccup/raw (format "
|
||||
(function () {
|
||||
var element = document.getElementById('%s');
|
||||
var c = new Choices(element, {removeItems: true, removeItemButton:true, searchFloor: 3, searchPlaceholderValue: '%s'});
|
||||
let baseUrl = '%s';
|
||||
|
||||
element.addEventListener('search', function (e) {
|
||||
let fullUrl = baseUrl + (baseUrl.includes(\"?\") ? \"&\" : \"?\") + \"q=\" + e.detail.value;
|
||||
let data = fetch(fullUrl)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
c.setChoices(data, 'value', 'label', true)
|
||||
});
|
||||
});
|
||||
element.addEventListener('choice', function (e) {
|
||||
c.clearChoices();
|
||||
})
|
||||
})();
|
||||
|
||||
"
|
||||
(:id params)
|
||||
(:placeholder params)
|
||||
(:url params)
|
||||
))]])
|
||||
|
||||
(defn typeahead-2- [params]
|
||||
[:div {:x-data (hx/json {:open false
|
||||
:baseUrl (if (str/includes? (:url params) "?")
|
||||
(str (:url params) "&q=")
|
||||
@@ -152,7 +115,6 @@ c.clearChoices();
|
||||
]])
|
||||
|
||||
|
||||
;; TODO fix search modal
|
||||
(defn use-size [size]
|
||||
(if (= :small size)
|
||||
(str " " "text-xs p-2")
|
||||
|
||||
Reference in New Issue
Block a user