Tiny JavaScript Plugin For Amazon Autocompletion

Category: Form , Javascript , Recommended | November 26, 2016
Author: caroso1222
Views Total: 1,774
Official Page: Go to website
Last Update: November 26, 2016
License: MIT

Preview:

Tiny JavaScript Plugin For Amazon Autocompletion

Description:

A small and easy-to-use JavaScript plugin for Amazon.com autocompletion that uses JSONP to fetch the product data from Amazon.

How to use it:

Copy and include the main JS file into the html page.

<script src="/path/to/amazon-autocomplete.min.js"></script>

Create a text field where you want to apply the Amazon Autocompletion to.

<input type="text" id="search-input">

Enable the Amazon Autocompletion on this text field.

let searchInput = new AmazonAutocomplete('#search-input');

Possible plugin options with default values.

let searchInput = new AmazonAutocomplete({
    selector: '#search-input',
    delay: 150,
    showWords: true,
    hideOnblur: true
});

API events.

// Log the selected word to the console
searchInput.onSelectedWord(word => console.log(`searching for ${word}...`));

// Populate your custom panel whenever there are new suggested words available
searchInput.onNewWords(words => words.forEach(word => addWordToCustomPanel(word)));

You Might Be Interested In:

Leave a Reply