mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-20 22:46:33 +02:00
Build
This commit is contained in:
parent
fc1b945ac9
commit
1b9e356033
|
@ -9,9 +9,9 @@ import Store from './store/index.js';
|
||||||
* Choices
|
* Choices
|
||||||
*
|
*
|
||||||
* To do:
|
* To do:
|
||||||
* - Map selected items to select options
|
|
||||||
* - Set input width based on the size of the contents
|
* - Set input width based on the size of the contents
|
||||||
* - Remove item by clicking a target
|
* - Remove item by clicking a target
|
||||||
|
* - Restoring input on .destroy()
|
||||||
*/
|
*/
|
||||||
export class Choices {
|
export class Choices {
|
||||||
constructor(element = '[data-choice]', userOptions = {}) {
|
constructor(element = '[data-choice]', userOptions = {}) {
|
||||||
|
@ -1097,13 +1097,14 @@ export class Choices {
|
||||||
|
|
||||||
// Add each list item to list
|
// Add each list item to list
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
// Create new list element
|
// Create a standard select option
|
||||||
const option = this.getTemplate('selectOption', item);
|
const option = this.getTemplate('selectOption', item);
|
||||||
|
|
||||||
// Append it to list
|
// Append it to fragment
|
||||||
selectedOptionsFragment.appendChild(option);
|
selectedOptionsFragment.appendChild(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update selected options
|
||||||
this.passedElement.innerHTML = "";
|
this.passedElement.innerHTML = "";
|
||||||
this.passedElement.appendChild(selectedOptionsFragment);
|
this.passedElement.appendChild(selectedOptionsFragment);
|
||||||
}
|
}
|
||||||
|
@ -1133,7 +1134,7 @@ export class Choices {
|
||||||
|
|
||||||
if(this.currentState !== this.prevState) {
|
if(this.currentState !== this.prevState) {
|
||||||
|
|
||||||
// OPTIONS
|
// Options
|
||||||
if((this.currentState.options !== this.prevState.options || this.currentState.groups !== this.prevState.groups)) {
|
if((this.currentState.options !== this.prevState.options || this.currentState.groups !== this.prevState.groups)) {
|
||||||
if(this.passedElement.type === 'select-multiple' || this.passedElement.type === 'select-one') {
|
if(this.passedElement.type === 'select-multiple' || this.passedElement.type === 'select-one') {
|
||||||
// Get active groups/options
|
// Get active groups/options
|
||||||
|
@ -1166,7 +1167,7 @@ export class Choices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ITEMS
|
// Items
|
||||||
if(this.currentState.items !== this.prevState.items) {
|
if(this.currentState.items !== this.prevState.items) {
|
||||||
const activeItems = this.store.getItemsFilteredByActive();
|
const activeItems = this.store.getItemsFilteredByActive();
|
||||||
if(activeItems) {
|
if(activeItems) {
|
||||||
|
|
Loading…
Reference in a new issue