Fix: auto selected if only one record
This commit is contained in:
parent
e3a1f317a8
commit
7444fd95e2
@ -92,8 +92,13 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='')
|
|||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){
|
jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){
|
||||||
response( jQuery.map( data, function( item ) {
|
response( jQuery.map( data, function( item ) {
|
||||||
var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
|
if (data.length == 1) {
|
||||||
return { label: label, value: item.value, id: item.key}
|
jQuery("#search_'.$htmlname.'").val(item.value);
|
||||||
|
jQuery("#'.$htmlname.'").val(item.key);
|
||||||
|
} else {
|
||||||
|
var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
|
||||||
|
return { label: label, value: item.value, id: item.key}
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}, "json");
|
}, "json");
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user