Syamsul 'isul' Arifin

kartunis dan desainer

Tue, Jun 14, 2016

Jquery script for Tapir

If you have a blog developed with static website generator, and you would add site search in it, Tapir may be is a choiche. There is documentation about how using tapir with jquery. But is not complete. I tried to code a Jquery script to use tapi eventhough i am not expert in Jquery. And…. this is the result, Jquery script to esecute Tapir. I have “debuged” this script and i think it’s working. This site, is the demo.

i assume that we have html script like this…

<form id="form">
  <input id="search" type="search" name="query">
  <input id="submit" type="button" value="submit">
<h2>Search results:</h2>
<div class="search_results">

and this is the Jquery script. Put this in html body before

<script src="{{ .Site.BaseURL }}js/jquery-2.2.4.min.js"></script>
<script src="{{ .Site.BaseURL }}js/jquery-tapir.min.js"></script>

<script type="text/javascript">
$( "#search" ).keypress(function( event ) {
if ( event.which == 13 ) {
var satu =  $( '#search' ).val(); 
window.location = '?query='+satu;
$( "#submit" ).click(function() {
$( "#search" ).keypress();
var satu =  $( "#search" ).val();   
window.location = '?query='+satu;
$('.search_results').tapir({'token': 'YOUR_TOKEN_HERE'});

inspiration link:

1. 2.

comments powered by Disqus