From cf9072349afa3b6d474f764fbe7e016f4f58337b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 13 Oct 2010 09:32:53 +0000 Subject: [PATCH] Fix: uniformize function (ready) --- htdocs/lib/ajax.lib.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index cfc508f383b..2fa6da8bb1f 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -147,11 +147,23 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='') //alert(fields + " " + length); jQuery("input#'.$htmlname.'").autocomplete({ - source: function( request, response ) { - jQuery.getJSON( "'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, response ); - }, - dataType: "json", + dataType: "json", minLength: 2, + source: function( request, response ) { + jQuery.getJSON( "'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){ + response( jQuery.map( data, function( item ) { + if (data.length == 1) { + jQuery("#'.$htmlname.'").val(item.value); + for (i=0;i