I'm not sure if its possible but I would like to make it so that jquery-ui autocomplete works with multiple keywords for the same result.
Here is an example but its rather old and I couldn't seem to get it to work, even with the older jquery files. I'm not that familiar with jquery and javascript but I can manage to edit existing things.
This is what I currently have (without any adjustments for the multi-keyword):
<script type="text/javascript">
$(document).ready(function() {
NewAuto();
});
function NewAuto() {
var products = [
<?php foreach($search__1 as $search) {
echo "{value: '". $search['product_name'] ."'}, ";}?>
];
$("#keyword").autocomplete({
source: function(requestObj, responseFunc) {
var matchArry = products.slice(); // Copy the array
var srchTerms = $.trim(requestObj.term).split(/\s+/);
// For each search term, remove non-matches.
$.each(srchTerms, function(J, term) {
var regX = new RegExp(term, "i");
matchArry = $.map(matchArry, function(item) {
return regX.test(item) ? item : null;
});
});
// Return the match results.
responseFunc(matchArry);
},
open: function(event, ui) {
// This function provides no hooks to the results list, so we have to trust the selector, for now.
var resultsList = $("ul.ui-autocomplete > li.ui-menu-item > a");
var srchTerm = $.trim($("#keyword").val()).split(/\s+/).join('|');
// Loop through the results list and highlight the terms.
resultsList.each(function() {
var jThis = $(this);
var regX = new RegExp('(' + srchTerm + ')', "ig");
var oldTxt = jThis.text();
jThis.html(oldTxt.replace(regX, '<span class="srchHilite">$1</span>'));
});
}
});
}
</script>