var requestAutoCompleteURL = "/catalog/solr_search_auto_complete.cmd"; function preventSpace(component){ if (document.getElementById(component.id).value.length == 0) { if (event.keyCode == 32) { event.preventDefault(); } } } function split(val) { return val.split( /,\s*/ ); } function extractLast(term) { return split(term).pop(); } function submitSearchForm(inputId,value,formId) { jQuery(inputId).val(value); jQuery(formId).submit(); } function callSolrSearch(inputId,formId,minChars){ jQuery(inputId).autocomplete({ source: function(request, response) { jQuery.ajax({ url: requestAutoCompleteURL, data: { keyword: request.term }, success: function(data) { response($.map(data, function(item) { return { label: item.autoCompleteKeyword, value: item.originalKeyword } })); } }); }, search: function() { var term = extractLast(this.value); if (term.length < minChars) { return false; } }, focus: function() { return false; }, minLength: minChars, select: function(event, ui) { submitSearchForm(inputId,ui.item.label,formId); } }).data("ui-autocomplete")._renderItem = function(ul, item) { return jQuery("