GithubHelp home page GithubHelp logo

vue-awesomplete's Introduction

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

Name Type Description
setting Object Setting of Awesomplete
ajax Object Setting of ajax request. There are three properties:
1. callback
Callback of ajax request. You must return array.
2. method
Set method of ajax request. Default using GET method.
3. url
Set url of ajax request

Methods

Name Description
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

Name Description
close The popup just closed.
highlight The highlighted item just changed.
open The popup just appeared.
select The user has made a selection (either via pressing enter or clicking on an item), but it has not been applied yet.
selectcomplete The 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.

vue-awesomplete's People

Contributors

sandi-racy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.