Skip to content

Instantly share code, notes, and snippets.

@zenorocha
Last active April 8, 2018 02:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zenorocha/476ddc57577f61800501 to your computer and use it in GitHub Desktop.
Save zenorocha/476ddc57577f61800501 to your computer and use it in GitHub Desktop.
var searchInput = document.querySelector('#search-input');
searchInput.addEventListener('input', function() { // Triggers when a user writes something
Launchpad // Uses Launchpad API Client to make an AJAX request
.url('http://liferay.io/docs/search/all') // Points to the API URL where the data is stored
.search('*', 'prefix', searchInput.value) // Filters results based on what the user typed
.highlight('content') // Automatically highlights the words that matched our query
.get() // Specifies what kind of HTTP request are we going to make
.then(function(result) {
// Renders the result in the page
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment