• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    HTML
  • Created almost 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

autocomplete/typeahead js plugin for bootstrap v5

bootstrap-5-autocomplete

This is a rewrite of https://github.com/Honatas/bootstrap-4-autocomplete for bootstrap v5.

Example

const ac = new Autocomplete(field, {
    data: [{label: "I'm a label", value: 42}],
    maximumItems: 5,
    onSelectItem: ({label, value}) => {
        console.log("user selected:", label, value);
    }
});

// later, when you need to change the dataset

ac.setData([
    {label: 'New York JFK', value: 'JFK'},
    {label: 'Moscow SVO', value: 'SVO'},
]);

Or use custom label/value keys:

const ac = new Autocomplete(field, {
    data: [{name: "entry1", text: "The first entry"}, {name: "entry2", text: "The second entry"}],
    label: "name",
    value: "text",
    onSelectItem: ({label, value}) => {
        console.log("user selected:", label, value);
    }
});

Or use a simple object instead of an array of objects:

const ac = new Autocomplete(field, {
    data: {entry1: "The first entry", entry2: "The second entry"},
    label: null,
    value: null,
    onSelectItem: ({label, value}) => {
        console.log("user selected:", label, value);
    }
});

Options

Options is a JSON object with the following attributes (in alphabetical order):

data:
The data from where autocomplete will lookup items to show. This data can be a simple object or an array of JSON objects. By default the format for every object in the array is as following, but you can also change the name of the label and value keys (see below):

{"label": "This is a text", "value": 42}

dropdownOptions:
It's the same options from Bootstrap's Dropdown, documented here.

dropdownClass:
The class of the dropdown-menu element, which is the box that is displayed. Can take a string or an array of strings.

highlightClass:
The class to use when highlighting typed text on items. Only used when highlightTyped is true. Default is text-primary. Can take a string or an array of strings.

highlightTyped:
Whether to highlight (style) typed text on items. Default is true.

label:
The name of the label key in your data. The label is what will be shown on each item in the autocomplete list.

maximumItems:
How many items you want to show when the autocomplete is displayed. Default is 5. Set to 0 to display all available items.

onInput:
A callback function to execute on user input.

onSelectItem:
A callback that is fired every time an item is selected. It receives an object in following format:

{label: <label>, value: <value>}

showValue:
If set to true, will display the value of the entry after the label in the dropdown list.

showValueBeforeLabel:
If set to true and showValue also set to true, the value will be displayed before the label.

threshold:
The number of characters that need to be typed on the input in order to trigger the autocomplete. Default is 4.

value:
The name of the value key in your data.

License

MIT

More Repositories

1

thinkpad-bios-software-flashing-guide

flashing coreboot on thinkpads without external programmer
Perl
226
star
2

sketchtrial

hack Sketch and make the trial never end
Objective-C
153
star
3

voidnsrun

Run glibc binaries in musl libc Void Linux environment
C
62
star
4

mmga

Script for flashing coreboot on MacBooks without using external SPI programmer
Shell
29
star
5

inverter-tools

advanced tools for voltronic inverters
C++
18
star
6

alsa-volume-monitor

C
11
star
7

mojave-permissions

node.js native addon for checking and requesting media permissions on macos
Objective-C++
9
star
8

jobd

simple job queue daemon
JavaScript
9
star
9

isv

Linux utility for controlling Voltronic hybrid solar inverters that use P18 protocol
C
7
star
10

smctool

Linux userspace tool to read Apple SMC keys
C
6
star
11

get_macbook_ramcfg

get MacBook's RAM configuration from inteltool -g dump
Python
4
star
12

polaris_pwk_1725cgld

Polaris PWK 1725CGLD smart kettle python library
Python
4
star
13

drm_master_util

suid program that helps to implement a workaround for using modesetting driver under rooless xorg
C
4
star
14

deadbeef-playlist

python library for reading and writing deadbeef binary playlists in dbpl format
Python
3
star
15

electron-ppapi-example

C++
3
star
16

captive-netns-helper

access captive portals without disabling wireguard or changing dns resolver on linux
C
3
star
17

vkflex-php

C
3
star
18

inverter-http-proxy

Python
3
star
19

pmh7tool

A tool to read, write, dump PMH7 registers
C
2
star
20

write-intel-brightness

Shell
2
star
21

tpl.js

Native JavaScript templates microlibrary
JavaScript
2
star
22

cf-wl

bash scripts to generate various whitelists for cloudflare networks
Shell
1
star
23

lrpb

last resort primitive backdoor
Shell
1
star
24

it2gpio

inteltool -g dump to gpio values
Python
1
star
25

fuck-adobe

endless photoshop/illustrator subscription for your macbook in 5 minutes
Python
1
star
26

vk-messages-post-archive

easily grab all your vk chat history with attachments
PHP
1
star
27

php-jobd-client

PHP client for jobd
PHP
1
star
28

node-vk-build-loader

JavaScript
1
star
29

inverter-bot

Simple Telegram bot for querying InfiniSolar V 5KW hybrid inverter, works with inverterd from inverter-tools. Also implements smart AC charging program and battery level notifications
Python
1
star