Skip to content
Snippets Groups Projects

Draft: feat: replace select2 with accessible selectize

Closed Jonáš Herec requested to merge feat-accesibility into main
<script>
$(document).ready(function () {
$("select.address").each(function () {
const select = $(this);
const defaultValue = select.data("selectize-default-value");
const option = new Option(defaultValue, defaultValue, true, true);
select.append(option);
});
$(document).ready(function () {
$("select.address").each(function () {
const select = $(this);
const defaultValue = select.data("selectize-default-value");
const option = new Option(defaultValue, defaultValue, true, true);
select.append(option);
});
const apiKey = $("select.address").data("selectize-api-key");
const categories = $("select.address").data("selectize-filter-categories");
const apiKey = $("select.address").data("selectize-api-key");
const categories = $("select.address").data("selectize-filter-categories");
$("select.address").selectize({
create: false,
persist: false,
openOnFocus: true,
valueField: 'text',
labelField: 'text',
searchField: 'text',
minimumInputLength: 5,
allowClear: true,
placeholder: "---",
load: function(query, callback) {
var data = {
text: query,
category: categories,
token: apiKey,
f: "json",
};
$.ajax({
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest",
dataType: "json",
data: data,
success: function(data) {
callback(data.suggestions.map((suggestion) => ({
text: suggestion.text,
id: suggestion.text,
})));
}
});
},
$("select.address").selectize({
create: false,
persist: false,
openOnFocus: true,
valueField: 'text',
labelField: 'text',
searchField: 'text',
minimumInputLength: 5,
allowClear: true,
placeholder: "---",
load: function(query, callback) {
var data = {
text: query,
category: categories,
token: apiKey,
f: "json",
};
$.ajax({
url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest",
dataType: "json",
data: data,
success: function(data) {
callback(data.suggestions.map((suggestion) => ({
text: suggestion.text,
id: suggestion.text,
})));
}
});
});
</script>
},
});
});
Loading