Autocomplete with SQL'statement "%"
When you use the SQL'statement "%" in the autocomplete, The list generated doesn't have the word searched marked in bold, because the autocomplete'function isn't prepared for this.
I did a adaptation to work with the the SQL'statement "%" that I will show below:
Original Function:
- $.Autocompleter.defaults={inputClass:"ac_input",
- ...
- highlight:function(value,term){
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),
"<strong>$1</strong>");
- },scroll:true,scrollHeight:180};
Adapted Function:
- $.Autocompleter.defaults={inputClass:"ac_input",
- ...
- highlight:function(value,term){
- // Create a array of words searched
- listTerm = term.split("%");
- /* Put in Bold each word searched
- * found in the list
- */
- for (i=0; i<listTerm.length; i++) {
- value = value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+listTerm[i].replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),
"<strong>$1</strong>");
- }
- return value;
- },scroll:true,scrollHeight:180};
I hope that Plugin'Developer insert this tip in the next version, Thanks.