Giter Club home page Giter Club logo

vue-autocomplete's Introduction

vue-autocomplete

The vue-autocomplete component offers simple and flexible type-ahead functionality. This is useful when searching large sets of data or even dynamically requesting information from an API.

vue-autocomplete-preview

Props

Props Description Type
id Specifies a unique id for an HTML element. String
placeholder A short hint that describes the expected value of input field. String
api GET List of items, optionally using pagination, sorting and filtering to navigate big lists. URI
attr An Object Key, representing the "rendered" text content of a dropdown-list element Object Key
value An Object Key, specifies the return string value of the list element on selection. Object Key
reset A true/false toggle to force reset/empty the input field. Boolean
text A String to force set the value of input field. String

Events

Events Description
tab Fired on Tab key Press & on selections.
selected Fired on Selection and returns entire selected object.
newVal Fired when input changes with the updated string value.

Instructions

Use GET requests to retrieve resource representation/information. URI Must end with a query parameter name & equal sign

Example request URIs:
  1. http://example.org/users?q=
  2. http://example.org/users?size=20&page=5&q=
Example Response
[
    {
        "name": "Edward F Woods"
        "address":"2356 Philadelphia Avenue",
        "phoneNumber":"801-261-4941"
    },
    {
        "name":"Stephen F Houser",
        "address":"896 Cedarstone Drive",
        "phoneNumber":"419-491-9630"
    }
]
Implementation
<template>
    <div>
        <AutoComplete
            id="search"
            placeholder="Eg: John Doe"
            attr="name"
            value="name"
            api="/users?q="
            @tab="$refs.age.focus()"
            @selected="selectUser"
            @newVal="
                val => {
                    person.name = val;
                }
            "
        />

        <!--Some other fields -->

        <input type="number" ref="age" />
    </div>
</template>
/>
import AutoComplete from "AutoComplete";

export default {
    data() {
        return {
            person: {
                name: "",
                address: "",
                phoneNumber: "",
            },
        };
    },

    methods: {
        selectUser(user) {
            this.person.address = user.address;
            this.person.phoneNumber = user.phoneNumber;
        },
    },

    components: {
        AutoComplete,
    },
};

CSS

Stylings uses Bootstrap CSS by default. Example:

Class Description
.active Adds a blue background color to the active dropdown item in a dropdown.

vue-autocomplete's People

Contributors

kritish-dhaubanjar avatar

Watchers

James Cloos 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.