Skip to content

Instantly share code, notes, and snippets.

@bigdawggi
Created March 20, 2015 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigdawggi/0189460108f3c2060f5b to your computer and use it in GitHub Desktop.
Save bigdawggi/0189460108f3c2060f5b to your computer and use it in GitHub Desktop.
Search with pretty permalinks
(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