sample jquery for dynamic display of lunr query results (for jekyll CI post)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('input#search').on('keyup', function () { | |
var resultdiv = $('#results'); | |
// Get query | |
var query = $(this).val(); | |
// Search for it | |
var result = idx.search(query); | |
// Show results | |
resultdiv.empty(); | |
for (var item in result) { | |
var ref = result[item].ref; | |
var searchitem = '<div class="result"><a href="'+store[ref].link+'">'+store[ref].title+'</a></div>'; | |
resultdiv.append(searchitem); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment