UNPKG

addsearch-search-ui

Version:

JavaScript library to develop Search UIs for the web

58 lines (50 loc) 1.87 kB
<!DOCTYPE html> <html lang="en"> <head> <title>AddSearch Search UI: Infinite scroll in a section</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700&display=swap" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/addsearch-js-client@0.6/dist/addsearch-js-client.min.js"></script> <script src="../../dist/addsearch-search-ui.min.js"></script> <link rel="stylesheet" href="../../dist/addsearch-search-ui.min.css" /> <style type="text/css"> body { font-family: 'Lato', sans-serif; min-width: 320px; } </style> </head> <body> <!-- Containers. Search UI components will be added inside these divs --> <div id="searchfield"></div> <!-- Scrollable section --> <section id="scroll" style="height: 500px; max-width: 1000px; border: 1px solid #000; overflow: auto;"> <div id="results"></div> <div id="loadMore"></div> </section> <script> // AddSearch JS client with an example index. Get your own SITEKEY by signing up at www.addsearch.com var client = new AddSearchClient('2c32bf3eb06b30af5f8208481aea3e8b'); // Search UI instance var searchui = new AddSearchUI(client); // Add components searchui.searchField({ containerId: 'searchfield', placeholder: 'Keyword..', button: 'Search', searchAsYouType: true }); searchui.searchResults({ containerId: 'results' }); searchui.loadMore({ containerId: 'loadMore', type: AddSearchUI.LOAD_MORE_TYPE.INFINITE_SCROLL, infiniteScrollElement: document.querySelector('#scroll') }); // All components added. Start searchui.start(); </script> </body> </html>