mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-13 19:32:21 +02:00
Attach choices to window
This commit is contained in:
parent
eb80a373df
commit
04ab5f6a98
4
assets/scripts/dist/bundle.js
vendored
4
assets/scripts/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1026,71 +1026,4 @@ export class Choices {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
window.Choices = module.exports = Choices;
|
||||||
const firstElement = document.getElementById('choices-1');
|
|
||||||
const choices1 = new Choices(firstElement, {
|
|
||||||
delimiter: ' ',
|
|
||||||
editItems: true,
|
|
||||||
maxItems: 5,
|
|
||||||
// callbackOnRemoveItem: function(value) {
|
|
||||||
// console.log(value);
|
|
||||||
// },
|
|
||||||
// callbackOnAddItem: function(id, value) {
|
|
||||||
// console.log(id, value);
|
|
||||||
// },
|
|
||||||
// callbackOnRender: function(items) {
|
|
||||||
// console.log(items);
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices2 = new Choices('#choices-2', {
|
|
||||||
allowPaste: false,
|
|
||||||
allowDuplicates: false,
|
|
||||||
editItems: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices3 = new Choices('#choices-3', {
|
|
||||||
allowDuplicates: false,
|
|
||||||
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,}))$/,
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices4 = new Choices('#choices-4', {
|
|
||||||
addItems: false,
|
|
||||||
removeItems: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices5 = new Choices('#choices-5', {
|
|
||||||
prependValue: 'item-',
|
|
||||||
appendValue: `-${Date.now()}`,
|
|
||||||
// callbackOnRender: function(items, options) {
|
|
||||||
// console.log(items);
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
|
|
||||||
choices5.removeAllItems();
|
|
||||||
|
|
||||||
const choices6 = new Choices('#choices-6', {
|
|
||||||
items: ['josh@joshuajohnson.co.uk', 'joe@bloggs.co.uk'],
|
|
||||||
// callbackOnRender: function(items, options, groups) {
|
|
||||||
// console.log(items);
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
|
|
||||||
const choices7 = new Choices('#choices-7', {
|
|
||||||
// callbackOnRender: function(items, options) {
|
|
||||||
// console.log(items);
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
|
|
||||||
const choicesMultiple = new Choices('[data-choice]', {
|
|
||||||
placeholderValue: 'This is a placeholder set in the config',
|
|
||||||
// callbackOnRender: function(items, options, groups) {
|
|
||||||
// console.log(options);
|
|
||||||
// },
|
|
||||||
});
|
|
||||||
|
|
||||||
// choices6.addItem('josh2@joshuajohnson.co.uk', null, null, () => { console.log('Custom add item callback')});
|
|
||||||
// choices6.removeItemsByValue('josh@joshuajohnson.co.uk');
|
|
||||||
// console.log(choices6.getItemById(3));
|
|
||||||
});
|
|
70
index.html
70
index.html
|
@ -70,5 +70,75 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const firstElement = document.getElementById('choices-1');
|
||||||
|
const choices1 = new Choices(firstElement, {
|
||||||
|
delimiter: ' ',
|
||||||
|
editItems: true,
|
||||||
|
maxItems: 5,
|
||||||
|
// callbackOnRemoveItem: function(value) {
|
||||||
|
// console.log(value);
|
||||||
|
// },
|
||||||
|
// callbackOnAddItem: function(id, value) {
|
||||||
|
// console.log(id, value);
|
||||||
|
// },
|
||||||
|
// callbackOnRender: function(items) {
|
||||||
|
// console.log(items);
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
const choices2 = new Choices('#choices-2', {
|
||||||
|
allowPaste: false,
|
||||||
|
allowDuplicates: false,
|
||||||
|
editItems: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const choices3 = new Choices('#choices-3', {
|
||||||
|
allowDuplicates: false,
|
||||||
|
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,}))$/,
|
||||||
|
});
|
||||||
|
|
||||||
|
const choices4 = new Choices('#choices-4', {
|
||||||
|
addItems: false,
|
||||||
|
removeItems: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const choices5 = new Choices('#choices-5', {
|
||||||
|
prependValue: 'item-',
|
||||||
|
appendValue: `-${Date.now()}`,
|
||||||
|
// callbackOnRender: function(items, options) {
|
||||||
|
// console.log(items);
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
choices5.removeAllItems();
|
||||||
|
|
||||||
|
const choices6 = new Choices('#choices-6', {
|
||||||
|
items: ['josh@joshuajohnson.co.uk', 'joe@bloggs.co.uk'],
|
||||||
|
// callbackOnRender: function(items, options, groups) {
|
||||||
|
// console.log(items);
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
const choices7 = new Choices('#choices-7', {
|
||||||
|
// callbackOnRender: function(items, options) {
|
||||||
|
// console.log(items);
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
const choicesMultiple = new Choices('[data-choice]', {
|
||||||
|
placeholderValue: 'This is a placeholder set in the config',
|
||||||
|
// callbackOnRender: function(items, options, groups) {
|
||||||
|
// console.log(options);
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
// choices6.addItem('josh2@joshuajohnson.co.uk', null, null, () => { console.log('Custom add item callback')});
|
||||||
|
// choices6.removeItemsByValue('josh@joshuajohnson.co.uk');
|
||||||
|
// console.log(choices6.getItemById(3));
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue