mirror of
https://github.com/Choices-js/Choices.git
synced 2024-04-30 13:02:48 +02:00
Ability to disable search
This commit is contained in:
parent
f361e4b34d
commit
7cfe84e9d1
4
assets/scripts/dist/choices.min.js
vendored
4
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -44,6 +44,7 @@ export class Choices {
|
|||
prependValue: false,
|
||||
appendValue: false,
|
||||
selectAll: true,
|
||||
loadingText: 'Loading...',
|
||||
templates: {},
|
||||
classNames: {
|
||||
containerOuter: 'choices',
|
||||
|
@ -128,7 +129,6 @@ export class Choices {
|
|||
} else {
|
||||
console.error('Choices: Incompatible input passed');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -400,16 +400,16 @@ export class Choices {
|
|||
|
||||
const hasShiftKey = e.shiftKey ? true : false;
|
||||
|
||||
// If input is not in focus, it ought to be
|
||||
if(this.input !== document.activeElement) {
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
if(this.passedElement.type !== 'text' && !this.dropdown.classList.contains(this.options.classNames.activeState)) {
|
||||
// For select inputs we always want to show the dropdown if it isn't already showing
|
||||
this.showDropdown();
|
||||
}
|
||||
|
||||
// If input is not in focus, it ought to be
|
||||
if(this.input !== document.activeElement) {
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
if(e.target.hasAttribute('data-button')) {
|
||||
if(this.options.removeItems && this.options.removeButton) {
|
||||
const itemId = e.target.parentNode.getAttribute('data-id');
|
||||
|
@ -470,6 +470,7 @@ export class Choices {
|
|||
* @return
|
||||
*/
|
||||
onPaste(e) {
|
||||
if(e.target !== this.input) return;
|
||||
// Disable pasting into the input if option has been set
|
||||
if(!this.options.allowPaste) {
|
||||
e.preventDefault();
|
||||
|
@ -909,7 +910,7 @@ export class Choices {
|
|||
*/
|
||||
ajax(fn) {
|
||||
this.containerOuter.classList.add('is-loading');
|
||||
this.input.placeholder = "Loading...";
|
||||
this.input.placeholder = this.options.loadingText;
|
||||
|
||||
const callback = (results, value, label) => {
|
||||
if(results && results.length) {
|
||||
|
@ -1056,7 +1057,7 @@ export class Choices {
|
|||
|
||||
if(this.passedElement.type === 'select-multiple' || this.passedElement.type === 'text') {
|
||||
containerInner.appendChild(input);
|
||||
} else {
|
||||
} else if(this.options.allowSearch) {
|
||||
dropdown.insertBefore(input, dropdown.firstChild);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
|
||||
const choices7 = new Choices('#choices-7');
|
||||
|
||||
const choicesAjax = new Choices('#choices-12').ajax((callback) => {
|
||||
const choicesAjax = new Choices('#choices-12', { allowSearch: false }).ajax((callback) => {
|
||||
fetch('https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
|
||||
.then((response) => {
|
||||
response.json().then(function(data) {
|
||||
|
|
Loading…
Reference in a new issue