Created
July 17, 2013 08:01
-
-
Save tisto/6018642 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/*jshint strict: true, undef: true*/ | |
/*global $,jQuery,window,document,localStorage,confirm,location,portal_url*/ | |
(function ($) { | |
"use strict"; | |
$("form#searchform").on("click", "input[type='submit']", function (event) { | |
event.preventDefault(); | |
$('#solr-suggestions').remove(); | |
var SearchableText = $("input[name='SearchableText']").val(); | |
var url = portal_url + "/@@suggest-terms?term=" + SearchableText; | |
$.ajax({ | |
url: url, | |
dataType: 'json', | |
success: function (data) { | |
if (data.length > 0) { | |
var suggestion_term = data[0].value.word; | |
var suggestion_link = portal_url + '/@@search?SearchableText=' + suggestion_term; | |
$('h1.documentFirstHeading').append( | |
$('<h4>', {'id': 'solr-suggestions'}) | |
.append('<span>Did you mean </span>') | |
.append('<a href="' + suggestion_link + '">' + suggestion_term + '</a>') | |
.append('<span>?</span>') | |
); | |
} | |
}, | |
}); | |
}); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment