Methods in Choices.js can be invoked by chaining them directly onto the constructor or by calling them on the instance returned by the constructor.
// Chaining methods
const choices = new Choices(element, {
addItems: false,
removeItems: false,
}).setValue(['Set value 1', 'Set value 2']).disable();
// Calling methods directly
const choices = new Choices(element, {
addItems: false,
removeItems: false,
});
choices.setValue(['Set value 1', 'Set value 2']);
choices.disable();
// Calling a method by chaining
const choices = new Choices(element, {
addItems: false,
removeItems: false,
})
.setValue(['Set value 1', 'Set value 2'])
.disable();
// Calling a method directly
const choices = new Choices(element, {
addItems: false,
removeItems: false,
});
choices.setValue(['Set value 1', 'Set value 2']);
choices.disable();