Skip to content

Instantly share code, notes, and snippets.

View awojtczyk's full-sized avatar
🐨

Andrzej Wojtczyk awojtczyk

🐨
View GitHub Profile
@awojtczyk
awojtczyk / search-form.js
Created December 15, 2017 10:08
Shopify ajax search
$(function() {
var currentAjaxRequest = null;
var searchForms = $('form[action="/search"]').css('position', 'relative').each(function() {
var input = $(this).find('input[name="q"]');
input.attr('autocomplete', 'off').bind('keyup change', function() {
var term = $(this).val();
var form = $(this).closest('form');
var searchURL = '/search?type=product&q=*' + term + '*';
var resultsList = $('.search-results');
resultsList.perfectScrollbar({