Created
March 20, 2015 16:24
-
-
Save bigdawggi/0189460108f3c2060f5b to your computer and use it in GitHub Desktop.
Search with pretty permalinks
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
(function($){ | |
$(function(){ | |
$('#search-form').on('submit', function(e){ | |
e.preventDefault(); | |
var searchBox = $(this).find('input[type=search]'), | |
searchTerm = ''; | |
if(searchBox.length === 0) { | |
alert('No search term available'); | |
return false; | |
} | |
var searchTerm = searchBox.val(); | |
if (searchTerm) { | |
var protocol = document.location.protocol, | |
hostname = document.location.hostname; | |
document.location.href = protocol + '//' + hostname + '/search/' + searchTerm; | |
} | |
}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment