2016-03-15 15:39:22 +01:00
<!DOCTYPE html>
< html lang = "en" >
< head >
2016-09-15 22:04:15 +02:00
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width,initial-scale=1,user-scalable=no" >
< title > Choices< / title >
< meta name = description itemprop = description content = "A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency." >
< link rel = "apple-touch-icon" sizes = "180x180" href = "assets/images/apple-touch-icon.png" >
< link rel = "icon" type = "image/png" href = "assets/images/favicon-32x32.png" sizes = "32x32" >
< link rel = "icon" type = "image/png" href = "assets/images/favicon-16x16.png" sizes = "16x16" >
< link rel = "manifest" href = "assets/images/manifest.json" >
< link rel = "mask-icon" href = "assets/images/safari-pinned-tab.svg" color = "#00bcd4" >
< link rel = "shortcut icon" href = "assets/images/favicon.ico" >
< meta name = "msapplication-config" content = "/assets/images/browserconfig.xml" >
< meta name = "theme-color" content = "#ffffff" >
<!-- Ignore these -->
2017-05-29 12:12:48 +02:00
< link rel = "stylesheet" href = "assets/styles/css/base.min.css?version=2.8.3" >
2016-09-15 22:04:15 +02:00
<!-- End ignore these -->
<!-- Optional includes -->
2017-01-01 17:06:09 +01:00
< script src = "https://cdn.polyfill.io/v2/polyfill.js?features=es5,fetch,Element.prototype.classList,requestAnimationFrame,Node.insertBefore,Node.firstChild,Object.assign" > < / script >
2016-09-15 22:04:15 +02:00
<!-- End optional includes -->
<!-- Choices includes -->
2017-05-29 12:12:48 +02:00
< link rel = "stylesheet" href = "assets/styles/css/choices.min.css?version=2.8.3" >
< script src = "assets/scripts/dist/choices.min.js?version=2.8.3" > < / script >
2016-09-15 22:04:15 +02:00
<!-- End Choices includes -->
<!-- [if lt IE 9]>
2016-09-21 14:32:21 +02:00
< style >
.hidden-ie { display: none; }
.visible-ie { display: block; }
< / style >
<![endif]-->
2016-03-15 15:39:22 +01:00
< / head >
< body >
2016-09-15 22:04:15 +02:00
< div class = "container" >
< div class = "section" >
2016-09-29 14:55:31 +02:00
< a href = "https://github.com/jshjohnson/Choices" class = "logo" >
< img src = "assets/images/logo.svg" alt = "Choices.js logo" class = "logo__img hidden-ie" >
< h1 class = "visible-ie" > Choices.js< / h1 >
< / a >
2016-09-15 22:04:15 +02:00
< p > Choices.js is a lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.< / p >
< p > For all config options, visit the < a href = "https://github.com/jshjohnson/Choices" > GitHub repo< / a > .< / p >
< hr >
< h2 > Text inputs< / h2 >
< label for = "choices-text-remove-button" > Limited to 5 values with remove button< / label >
< input class = "form-control" id = "choices-text-remove-button" type = "text" value = "preset-1,preset-2" placeholder = "Enter something" >
< label for = "choices-text-unique-values" > Unique values only, no pasting< / label >
< input class = "form-control" id = "choices-text-unique-values" type = "text" value = "preset-1, preset-2" placeholder = "This is a placeholder" class = "custom class" >
< label for = "choices-text-email-filter" > Email addresses only< / label >
< input class = "form-control" id = "choices-text-email-filter" type = "text" placeholder = "This is a placeholder" >
< label for = "choices-text-disabled" > Disabled< / label >
< input class = "form-control" id = "choices-text-disabled" type = "text" value = "josh@joshuajohnson.co.uk, joe@bloggs.co.uk" placeholder = "This is a placeholder" >
< label for = "choices-text-prepend-append-value" > Prepends and appends a value to each items return value< / label >
< input class = "form-control" id = "choices-text-prepend-append-value" type = "text" value = "preset-1, preset-2" placeholder = "This is a placeholder" >
< label for = "choices-text-preset-values" > Preset values passed through options< / label >
< input class = "form-control" id = "choices-text-preset-values" type = "text" value = "olivia@benson.com" placeholder = "This is a placeholder" >
2016-11-07 11:27:04 +01:00
< label for = "choices-text-i18n" > I18N labels< / label >
< input class = "form-control" data-trigger id = "choices-text-i18n" type = "text" >
< label for = "choices-text-rtl" > Right-to-left< / label >
2016-10-12 14:54:14 +02:00
< input class = "form-control" data-trigger id = "choices-text-rtl" type = "text" value = "Value 1, Value 2" dir = "rtl" >
2016-09-15 22:04:15 +02:00
< hr >
< h2 > Multiple select input< / h2 >
< label for = "choices-multiple-default" > Default< / label >
2016-10-12 14:54:14 +02:00
< select class = "form-control" data-trigger name = "choices-multiple-default" id = "choices-multiple-default" placeholder = "This is a placeholder" multiple >
2016-09-21 14:32:21 +02:00
< option value = "Dropdown item 1" selected > Dropdown item 1< / option >
< option value = "Dropdown item 2" > Dropdown item 2< / option >
< option value = "Dropdown item 3" > Dropdown item 3< / option >
< option value = "Dropdown item 4" disabled > Dropdown item 4< / option >
2016-09-15 22:04:15 +02:00
< / select >
2016-10-12 14:54:14 +02:00
< label for = "choices-multiple-remove-button" > With remove button< / label >
< select class = "form-control" name = "choices-multiple-remove-button" id = "choices-multiple-remove-button" placeholder = "This is a placeholder" multiple >
< option value = "Dropdown item 1" selected > Dropdown item 1< / option >
< option value = "Dropdown item 2" > Dropdown item 2< / option >
< option value = "Dropdown item 3" > Dropdown item 3< / option >
< option value = "Dropdown item 4" > Dropdown item 4< / option >
< / select >
2016-09-15 22:04:15 +02:00
< label for = "choices-multiple-groups" > Option groups< / label >
2016-10-18 20:23:07 +02:00
< select class = "form-control" name = "choices-multiple-groups" id = "choices-multiple-groups" placeholder = "This is a placeholder" multiple >
2016-09-21 14:32:21 +02:00
< optgroup label = "UK" >
< option value = "London" > London< / option >
< option value = "Manchester" > Manchester< / option >
< option value = "Liverpool" > Liverpool< / option >
< / optgroup >
< optgroup label = "FR" >
< option value = "Paris" > Paris< / option >
< option value = "Lyon" > Lyon< / option >
< option value = "Marseille" > Marseille< / option >
< / optgroup >
< optgroup label = "DE" disabled >
< option value = "Hamburg" > Hamburg< / option >
< option value = "Munich" > Munich< / option >
< option value = "Berlin" > Berlin< / option >
< / optgroup >
< optgroup label = "US" >
< option value = "New York" > New York< / option >
< option value = "Washington" disabled > Washington< / option >
< option value = "Michigan" > Michigan< / option >
< / optgroup >
< optgroup label = "SP" >
< option value = "Madrid" > Madrid< / option >
< option value = "Barcelona" > Barcelona< / option >
< option value = "Malaga" > Malaga< / option >
< / optgroup >
< optgroup label = "CA" >
< option value = "Montreal" > Montreal< / option >
< option value = "Toronto" > Toronto< / option >
< option value = "Vancouver" > Vancouver< / option >
< / optgroup >
2016-09-15 22:04:15 +02:00
< / select >
2016-09-29 14:52:08 +02:00
< p > < small > If the following example do not load, the Discogs rate limit has probably been reached. Try again later!< / small > < / p >
2016-09-15 22:04:15 +02:00
< label for = "choices-multiple-remote-fetch" > Options from remote source (Fetch API) & limited to 5< / label >
< select class = "form-control" name = "choices-multiple-remote-fetch" id = "choices-multiple-remote-fetch" multiple > < / select >
< label for = "choices-multiple-rtl" > Right-to-left< / label >
2016-10-12 14:54:14 +02:00
< select class = "form-control" data-trigger name = "choices-multiple-rtl" id = "choices-multiple-rtl" placeholder = "This is a placeholder" multiple dir = "rtl" >
2016-09-21 14:32:21 +02:00
< option value = "Dropdown item 1" selected > Dropdown item 1< / option >
< option value = "Dropdown item 2" > Dropdown item 2< / option >
< option value = "Dropdown item 3" > Dropdown item 3< / option >
< option value = "Dropdown item 4" disabled > Dropdown item 4< / option >
2016-09-15 22:04:15 +02:00
< / select >
2017-03-28 15:41:12 +02:00
< label for = "label-event" > Use label in event (add/remove)< / label >
< p id = "message" > < / p >
< select id = "choices-multiple-labels" multiple > < / select >
2016-09-15 22:04:15 +02:00
< hr >
< h2 > Single select input< / h2 >
< label for = "choices-single-default" > Default< / label >
2016-10-12 14:54:14 +02:00
< select class = "form-control" data-trigger name = "choices-single-default" id = "choices-single-default" placeholder = "This is a search placeholder" >
2016-09-21 14:32:21 +02:00
< option selected disabled > This is a placeholder< / option >
< option value = "Dropdown item 1" > Dropdown item 1< / option >
< option value = "Dropdown item 2" > Dropdown item 2< / option >
< option value = "Dropdown item 3" > Dropdown item 3< / option >
2016-09-15 22:04:15 +02:00
< / select >
2016-09-29 14:52:08 +02:00
< p > < small > If the following two examples do not load, the Discogs rate limit has probably been reached. Try again later!< / small > < / p >
2016-09-15 22:04:15 +02:00
< label for = "choices-single-remote-fetch" > Options from remote source (Fetch API)< / label >
< select class = "form-control" name = "choices-single-remote-fetch" id = "choices-single-remote-fetch" placeholder = "Pick an Arctic Monkeys record" > < / select >
< label for = "choices-single-remove-xhr" > Options from remote source (XHR) & remove button< / label >
< select class = "form-control" name = "choices-single-remove-xhr" id = "choices-single-remove-xhr" placeholder = "Pick a Smiths record" > < / select >
< label for = "choices-single-groups" > Option groups< / label >
2016-10-12 14:54:14 +02:00
< select class = "form-control" data-trigger name = "choices-single-groups" id = "choices-single-groups" placeholder = "This is a placeholder" >
2016-09-21 14:32:21 +02:00
< optgroup label = "UK" >
< option value = "London" > London< / option >
< option value = "Manchester" > Manchester< / option >
< option value = "Liverpool" > Liverpool< / option >
< / optgroup >
< optgroup label = "FR" >
< option value = "Paris" > Paris< / option >
< option value = "Lyon" > Lyon< / option >
< option value = "Marseille" > Marseille< / option >
< / optgroup >
< optgroup label = "DE" disabled >
< option value = "Hamburg" > Hamburg< / option >
< option value = "Munich" > Munich< / option >
< option value = "Berlin" > Berlin< / option >
< / optgroup >
< optgroup label = "US" >
< option value = "New York" > New York< / option >
< option value = "Washington" disabled > Washington< / option >
< option value = "Michigan" > Michigan< / option >
< / optgroup >
< optgroup label = "SP" >
< option value = "Madrid" > Madrid< / option >
< option value = "Barcelona" > Barcelona< / option >
< option value = "Malaga" > Malaga< / option >
< / optgroup >
< optgroup label = "CA" >
< option value = "Montreal" > Montreal< / option >
< option value = "Toronto" > Toronto< / option >
< option value = "Vancouver" > Vancouver< / option >
< / optgroup >
2016-09-15 22:04:15 +02:00
< / select >
< label for = "choices-single-rtl" > Right-to-left< / label >
2016-10-12 14:54:14 +02:00
< select class = "form-control" data-trigger name = "choices-single-rtl" id = "choices-single-rtl" placeholder = "This is a placeholder" dir = "rtl" >
2016-09-21 14:32:21 +02:00
< option value = "Dropdown item 1" > Dropdown item 1< / option >
< option value = "Dropdown item 2" > Dropdown item 2< / option >
< option value = "Dropdown item 3" > Dropdown item 3< / option >
2016-09-15 22:04:15 +02:00
< / select >
< label for = "choices-single-no-search" > Options added via config with no search< / label >
< select class = "form-control" name = "choices-single-no-search" id = "choices-single-no-search" >
2016-09-21 14:32:21 +02:00
< option value = "0" > Zero< / option >
2016-09-15 22:04:15 +02:00
< / select >
< label for = "choices-single-preset-options" > Option and option groups added via config< / label >
< select class = "form-control" name = "choices-single-preset-options" id = "choices-single-preset-options" placeholder = "This is a placeholder" > < / select >
< label for = "choices-single-selected-option" > Option selected via config< / label >
< select class = "form-control" name = "choices-single-selected-option" id = "choices-single-selected-option" placeholder = "This is a placeholder" > < / select >
< label for = "choices-single-no-sorting" > Options without sorting< / label >
< select class = "form-control" name = "choices-single-no-sorting" id = "choices-single-no-sorting" placeholder = "This is a placeholder" >
2016-09-21 14:32:21 +02:00
< option value = "Madrid" > Madrid< / option >
< option value = "Toronto" > Toronto< / option >
< option value = "Vancouver" > Vancouver< / option >
< option value = "London" > London< / option >
< option value = "Manchester" > Manchester< / option >
< option value = "Liverpool" > Liverpool< / option >
< option value = "Paris" > Paris< / option >
< option value = "Malaga" > Malaga< / option >
< option value = "Washington" disabled > Washington< / option >
< option value = "Lyon" > Lyon< / option >
< option value = "Marseille" > Marseille< / option >
< option value = "Hamburg" > Hamburg< / option >
< option value = "Munich" > Munich< / option >
< option value = "Barcelona" > Barcelona< / option >
< option value = "Berlin" > Berlin< / option >
< option value = "Montreal" > Montreal< / option >
< option value = "New York" > New York< / option >
< option value = "Michigan" > Michigan< / option >
2016-09-15 22:04:15 +02:00
< / select >
2017-03-28 15:41:12 +02:00
< label for = "choices-single-custom-templates" > Custom templates< / label >
< select class = "form-control" name = "choices-single-custom-templates" id = "choices-single-custom-templates" placeholder = "This is a placeholder" >
2016-09-30 14:50:23 +02:00
< option value = "React" > React< / option >
2017-03-31 10:09:22 +02:00
< option value = "Angular" > Angular< / option >
< option value = "Ember" > Ember< / option >
< option value = "Vue" > Vue< / option >
2016-09-30 14:50:23 +02:00
< / select >
2016-09-15 22:04:15 +02:00
< p > Below is an example of how you could have two select inputs depend on eachother. 'Boroughs' will only be enabled if the value of 'States' is 'New York'< / p >
< label for = "states" > States< / label >
< select class = "form-control" name = "states" id = "states" placeholder = "Choose a state" >
2016-09-21 14:32:21 +02:00
< option value = "Michigan" > Michigan< / option >
< option value = "Texas" > Texas< / option >
< option value = "Chicago" > Chicago< / option >
< option value = "New York" > New York< / option >
< option value = "Washington" > Washington< / option >
2016-09-15 22:04:15 +02:00
< / select >
< label for = "boroughs" > Boroughs< / label >
< select class = "form-control" name = "boroughs" id = "boroughs" placeholder = "Choose a borough" >
2016-09-21 14:32:21 +02:00
< option value = "The Bronx" > The Bronx< / option >
< option value = "Brooklyn" > Brooklyn< / option >
< option value = "Manhattan" > Manhattan< / option >
< option value = "Queens" > Queens< / option >
< option value = "Staten Island" > Staten Island< / option >
2016-09-15 22:04:15 +02:00
< / select >
2016-04-04 15:43:22 +02:00
< / div >
2016-09-15 22:04:15 +02:00
< / div >
< script >
document.addEventListener('DOMContentLoaded', function() {
2016-09-27 21:07:32 +02:00
var textRemove = new Choices(document.getElementById('choices-text-remove-button'), {
2016-09-21 14:32:21 +02:00
delimiter: ',',
editItems: true,
maxItemCount: 5,
removeItemButton: true,
});
2016-09-27 21:07:32 +02:00
var textUniqueVals = new Choices('#choices-text-unique-values', {
2016-09-21 14:32:21 +02:00
paste: false,
duplicateItems: false,
editItems: true,
});
2016-11-07 11:27:04 +01:00
var texti18n = new Choices('#choices-text-i18n', {
paste: false,
duplicateItems: false,
editItems: true,
2017-03-31 10:09:22 +02:00
maxItemCount: 5,
addItemText: function(value) {
2017-03-31 10:23:01 +02:00
return 'Appuyez sur Entrée pour ajouter < b > "' + String(value) + '"< / b > ';
2016-11-07 11:27:04 +01:00
},
2017-03-31 10:09:22 +02:00
maxItemText: function(maxItemCount) {
2017-03-31 10:23:01 +02:00
return String(maxItemCount) + 'valeurs peuvent être ajoutées';
2016-11-07 11:27:04 +01:00
},
uniqueItemText: 'Cette valeur est déjà présente',
});
2016-09-27 21:07:32 +02:00
var textEmailFilter = new Choices('#choices-text-email-filter', {
2016-09-21 14:32:21 +02:00
editItems: true,
regexFilter: /^(([^< >()\[\]\\.,;:\s@"]+(\.[^< >()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
2017-02-17 10:23:52 +01:00
}).setValue(['joe@bloggs.com']);
2016-09-21 14:32:21 +02:00
2016-09-27 21:07:32 +02:00
var textDisabled = new Choices('#choices-text-disabled', {
2016-09-21 14:32:21 +02:00
addItems: false,
removeItems: false,
}).disable();
2016-09-27 21:07:32 +02:00
var textPrependAppendVal = new Choices('#choices-text-prepend-append-value', {
2016-09-21 14:32:21 +02:00
prependValue: 'item-',
appendValue: '-' + Date.now(),
}).removeActiveItems();
2016-09-27 21:07:32 +02:00
var textPresetVal = new Choices('#choices-text-preset-values', {
2016-09-21 14:32:21 +02:00
items: ['josh@joshuajohnson.co.uk', { value: 'joe@bloggs.co.uk', label: 'Joe Bloggs' } ],
});
2017-01-01 16:32:09 +01:00
var multipleDefault = new Choices(document.getElementById('choices-multiple-groups'));
2016-10-18 20:23:07 +02:00
2016-09-27 21:07:32 +02:00
var multipleFetch = new Choices('#choices-multiple-remote-fetch', {
2016-09-21 14:32:21 +02:00
placeholder: true,
placeholderValue: 'Pick an Strokes record',
maxItemCount: 5,
}).ajax(function(callback) {
fetch('https://api.discogs.com/artists/55980/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
.then(function(response) {
response.json().then(function(data) {
callback(data.releases, 'title', 'title');
});
})
.catch(function(error) {
2017-01-01 16:32:09 +01:00
console.error(error);
2016-09-15 22:04:15 +02:00
});
2016-09-21 14:32:21 +02:00
});
2016-10-12 14:54:14 +02:00
var multipleCancelButton = new Choices('#choices-multiple-remove-button', {
removeItemButton: true,
2017-03-28 15:41:12 +02:00
});
/* Use label on event */
var choicesSelect = new Choices('#choices-multiple-labels', {
removeItemButton: true,
choices: [
{value: 'One', label: 'Label One'},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
],
}).setChoices([
{value: 'Four', label: 'Label Four', disabled: true},
{value: 'Five', label: 'Label Five'},
{value: 'Six', label: 'Label Six', selected: true},
], 'value', 'label', false);
choicesSelect.passedElement.addEventListener('addItem', function(event) {
document.getElementById('message').innerHTML = 'You just added "' + event.detail.label + '"';
});
choicesSelect.passedElement.addEventListener('removeItem', function(event) {
document.getElementById('message').innerHTML = 'You just removed "' + event.detail.label + '"';
});
2016-10-12 14:54:14 +02:00
2016-09-27 21:07:32 +02:00
var singleFetch = new Choices('#choices-single-remote-fetch', {
2016-09-21 14:32:21 +02:00
placeholder: true,
placeholderValue: 'Pick an Arctic Monkeys record'
}).ajax(function(callback) {
fetch('https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
.then(function(response) {
response.json().then(function(data) {
callback(data.releases, 'title', 'title');
2016-09-27 21:07:32 +02:00
singleFetch.setValueByChoice('Fake Tales Of San Francisco');
2016-09-21 14:32:21 +02:00
});
})
.catch(function(error) {
2017-01-01 16:32:09 +01:00
console.error(error);
2016-09-15 22:04:15 +02:00
});
2016-09-21 14:32:21 +02:00
});
2016-09-27 21:07:32 +02:00
var singleXhrRemove = new Choices('#choices-single-remove-xhr', {
2016-09-21 14:32:21 +02:00
removeItemButton: true,
}).ajax(function(callback) {
var request = new XMLHttpRequest();
request.open('get', 'https://api.discogs.com/artists/83080/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW', true);
request.onreadystatechange = function() {
var status;
var data;
if (request.readyState === 4) {
status = request.status;
if (status === 200) {
data = JSON.parse(request.responseText);
callback(data.releases, 'title', 'title');
2016-09-27 21:07:32 +02:00
singleXhrRemove.setValueByChoice('How Soon Is Now?');
2016-09-21 14:32:21 +02:00
} else {
2017-01-01 16:32:09 +01:00
console.error(status);
2016-09-21 14:32:21 +02:00
}
}
}
request.send();
});
2016-10-12 14:54:14 +02:00
var genericExamples = new Choices('[data-trigger]', {
placeholderValue: 'This is a placeholder set in the config'
2016-09-21 14:32:21 +02:00
});
2016-09-27 21:07:32 +02:00
var singleNoSearch = new Choices('#choices-single-no-search', {
2017-05-18 18:56:29 +02:00
searchEnabled: false,
2016-09-21 14:32:21 +02:00
removeItemButton: true,
choices: [
2016-09-27 14:44:35 +02:00
{value: 'One', label: 'Label One'},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
2016-09-21 14:32:21 +02:00
],
}).setChoices([
2016-09-27 14:44:35 +02:00
{value: 'Four', label: 'Label Four', disabled: true},
{value: 'Five', label: 'Label Five'},
{value: 'Six', label: 'Label Six', selected: true},
2016-10-19 08:33:38 +02:00
], 'value', 'label', false);
2016-09-21 14:32:21 +02:00
2016-09-27 21:07:32 +02:00
var singlePresetOpts = new Choices('#choices-single-preset-options', {
2016-09-21 14:32:21 +02:00
placeholder: true,
}).setChoices([{
label: 'Group one',
id: 1,
disabled: false,
choices: [
2016-09-27 14:44:35 +02:00
{value: 'Child One', label: 'Child One', selected: true},
{value: 'Child Two', label: 'Child Two', disabled: true},
{value: 'Child Three', label: 'Child Three'},
2016-09-21 14:32:21 +02:00
]
},
{
label: 'Group two',
id: 2,
disabled: false,
choices: [
2016-09-27 14:44:35 +02:00
{value: 'Child Four', label: 'Child Four', disabled: true},
{value: 'Child Five', label: 'Child Five'},
{value: 'Child Six', label: 'Child Six'},
2016-09-21 14:32:21 +02:00
]
}], 'value', 'label');
2016-09-27 21:07:32 +02:00
var singleSelectedOpt = new Choices('#choices-single-selected-option', {
2016-09-21 14:32:21 +02:00
choices: [
2016-09-27 14:44:35 +02:00
{value: 'One', label: 'Label One', selected: true},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
2016-09-21 14:32:21 +02:00
],
}).setValueByChoice('Two');
2016-09-27 21:07:32 +02:00
var singleNoSorting = new Choices('#choices-single-no-sorting', {
2016-09-21 14:32:21 +02:00
shouldSort: false,
});
2017-01-01 16:32:09 +01:00
var states = new Choices(document.getElementById('states'));
states.passedElement.addEventListener('change', function(e) {
if(e.detail.value === 'New York') {
boroughs.enable();
} else {
boroughs.disable();
2016-09-21 14:32:21 +02:00
}
});
2017-03-28 15:41:12 +02:00
var customTemplates = new Choices(document.getElementById('choices-single-custom-templates'), {
2016-11-07 14:53:56 +01:00
callbackOnCreateTemplates: function (strToEl) {
var classNames = this.config.classNames;
2017-03-31 10:09:22 +02:00
var itemSelectText = this.config.itemSelectText;
2016-09-30 14:05:05 +02:00
return {
2017-03-31 10:09:22 +02:00
item: function(data) {
2017-03-31 10:23:01 +02:00
return strToEl('\
< div \
class="'+ String(classNames.item) + ' ' + String(data.highlighted ? classNames.highlightedState : classNames.itemSelectable) + '"\
data-item\
data-id="'+ String(data.id) + '"\
data-value="'+ String(data.value) +'"\
'+ String(data.active ? 'aria-selected="true"' : '') + '\
'+ String(data.disabled ? 'aria-disabled="true"' : '') + '\
>\
< span style = "margin-right:10px;" > 🎉< / span > ' + String(data.label) + '\
< / div > \
');
2016-09-30 14:19:05 +02:00
},
2017-03-31 10:09:22 +02:00
choice: function(data) {
2017-03-31 10:23:01 +02:00
return strToEl('\
< div \
class="'+ String(classNames.item) + ' ' + String(classNames.itemChoice) + ' ' + String(data.disabled ? classNames.itemDisabled : classNames.itemSelectable) + '"\
data-select-text="'+ String(itemSelectText) +'"\
data-choice \
'+ String(data.disabled ? 'data-choice-disabled aria-disabled="true"' : 'data-choice-selectable') + '\
data-id="'+ String(data.id) +'"\
data-value="'+ String(data.value) +'"\
'+ String(data.groupId > 0 ? 'role="treeitem"' : 'role="option"') + '\
>\
< span style = "margin-right:10px;" > 👉🏽< / span > ' + String(data.label) + '\
< / div > \
');
2016-09-30 14:05:05 +02:00
},
};
}
});
2016-09-21 14:32:21 +02:00
var boroughs = new Choices(document.getElementById('boroughs')).disable();
2016-09-15 22:04:15 +02:00
});
< / script >
<!-- Google Analytics - Ignore me -->
< script >
2016-09-21 14:32:21 +02:00
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-31575166-1', 'auto');
ga('send', 'pageview');
2016-09-15 22:04:15 +02:00
< / script >
< script async src = 'https://www.google-analytics.com/analytics.js' > < / script >
<!-- End Google Analytics -->
2016-03-15 15:39:22 +01:00
< / body >
2016-09-24 11:52:05 +02:00
< / html >