From a8e1ab66777e9c0895ccec5dcc1233d4d21f5dc6 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 1 Jul 2020 14:49:50 +0300 Subject: [PATCH] Updated autocomplete demo --- src/views/autocomplete/AutoCompleteDemo.vue | 62 +++-------- src/views/autocomplete/AutoCompleteDoc.vue | 110 +++++++------------- 2 files changed, 56 insertions(+), 116 deletions(-) diff --git a/src/views/autocomplete/AutoCompleteDemo.vue b/src/views/autocomplete/AutoCompleteDemo.vue index 0e5a99208..a2364b123 100755 --- a/src/views/autocomplete/AutoCompleteDemo.vue +++ b/src/views/autocomplete/AutoCompleteDemo.vue @@ -11,27 +11,21 @@
Basic
- - Country: {{selectedCountry || 'none'}} - +
Dropdown and Templating
- + - Brand: {{brand || 'none'}}
Multiple
- + -
    -
  • {{c}}
  • -
@@ -47,13 +41,10 @@ export default { data() { return { countries: null, - selectedCountry: null, - filteredCountriesBasic: null, - selectedCountries: [], - filteredCountriesMultiple: null, - brands: null, - brand: null, - filteredBrands: null + selectedCountry1: null, + selectedCountry2: null, + filteredCountries: null, + selectedCountries: [] } }, countryService: null, @@ -62,38 +53,18 @@ export default { }, mounted() { this.countryService.getCountries().then(data => this.countries = data); - this.brands = ['Audi', 'BMW', 'Fiat', 'Ford', 'Honda', 'Jaguar', 'Mercedes', 'Renault', 'Volvo']; }, methods: { - searchCountry(query) { - return this.countries.filter((country) => { - return country.name.toLowerCase().startsWith(query.toLowerCase()); - }); - }, - searchCountryBasic(event) { + searchCountry(event) { setTimeout(() => { - this.filteredCountriesBasic = this.searchCountry(event.query); - }, 250); - }, - searchCountryMultiple(event) { - setTimeout(() => { - this.filteredCountriesMultiple = this.searchCountry(event.query); - }, 250); - }, - searchBrand(event) { - setTimeout(() => { - let results; - - if (event.query.length === 0) { - results = [...this.brands]; + if (!event.query.trim().length) { + this.filteredCountries = [...this.countries]; } else { - results = this.brands.filter((brand) => { - return brand.toLowerCase().startsWith(event.query.toLowerCase()); + this.filteredCountries = this.countries.filter((country) => { + return country.name.toLowerCase().startsWith(event.query.toLowerCase()); }); } - - this.filteredBrands = results; }, 250); } }, @@ -104,10 +75,9 @@ export default {