0.1.8 • Published 7 years ago

vue-awesomplete v0.1.8

Weekly downloads
28
License
MIT
Repository
github
Last release
7 years ago

vue-awesomplete

Vue wrapper for Awesomplete

Install

yarn add vue-awesomplete

Basic Usage

<template>
  <vue-awesomplete :setting="{ list: ['Html', 'CSS', 'Javascript', 'PHP'] }"></vue-awesomplete>
</template>

<script>
  import VueAwesomplete from 'vue-awesomplete'

  export default {
    components: {
      VueAwesomplete
    }
  }
</script>

Dont forget to include awesomplete.css

<link rel="stylesheet" href="awesomplete.css" />

Or if you use style-loader and css-loader

import AwesompleteCss from 'awesomplete/awesomplete.css'

You can even set it (or override it) later and it will just work

<template>
  <vue-awesomplete :setting="{ list: ['Html', 'CSS', 'Javascript', 'PHP'] }" ref="skills"></vue-awesomplete>
  <button @click="changeSkills">Change Skills</button>
</template>

<script>
  import VueAwesomplete from 'vue-awesomplete'

  export default {
    methods: {
      changeSkills() {
        this.$refs.skills.list(['Angular', 'React', 'Vue'])
      }
    },
  
    components: {
      VueAwesomplete
    }
  }
</script>

Ajax Example

<template>
  <vue-awesomplete :ajax="ajax"></vue-awesomplete>
</template>

<script>
  import VueAwesomplete from 'vue-awesomplete'

  export default {
    data() {
      return {
        ajax: {
          callback: function (response) {
            return response.map(function(i) {
              return i.name
            })
          },
          url: 'https://restcountries.eu/rest/v1/lang/fr'
        }
      }
    },

    components: {
      VueAwesomplete
    }
  }
</script>

Props

NameTypeDescription
settingObjectSetting of Awesomplete
ajaxObjectSetting of ajax request. There are three properties:1. callbackCallback of ajax request. You must return array.2. methodSet method of ajax request. Default using GET method.3. urlSet url of ajax request

Methods

NameDescription
close()Closes the popup.
destroy()Clean up and remove the instance from the input.
evaluate()Evaluates the current state of the widget and regenerates the list of suggestions or closes the popup if none are available. You need to call it if you dynamically set list while the popup is open.
goto(i)Highlights the item with index i in the popup (-1 to deselect all). Avoid using this directly and try to use next() or previous() instead when possible.
next()Highlights the next item in the popup.
open()Opens the popup.
previous()Highlights the previous item in the popup.
select()Selects the currently highlighted item, replaces the text field’s value with it and closes the popup.

Events

NameDescription
closeThe popup just closed.
highlightThe highlighted item just changed.
openThe popup just appeared.
selectThe user has made a selection (either via pressing enter or clicking on an item), but it has not been applied yet.
selectcompleteThe user has made a selection (either via pressing enter or clicking on an item), and it has been applied

License

vue-awesomplete is released under the MIT License.

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago