2
0
forked from Wavyzz/dolibarr

Fix: uniformize json with search company

Fix: search product with jQuery
This commit is contained in:
Regis Houssin
2010-10-11 09:14:21 +00:00
parent cfa3e3c9cf
commit c1b8055538
5 changed files with 15 additions and 14 deletions

View File

@@ -80,7 +80,7 @@ function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
* \param url chemin du fichier de reponse : /chemin/fichier.php
* \return string script complet
*/
function ajax_autocompleter($selected='',$htmlname,$valname,$url)
function ajax_autocompleter($selected='',$htmlname,$url,$option='')
{
$script='';
@@ -90,10 +90,10 @@ function ajax_autocompleter($selected='',$htmlname,$valname,$url)
$script.= 'jQuery(document).ready(function() {
jQuery("input#search_'.$htmlname.'").autocomplete({
source: function( request, response ) {
jQuery.get("'.$url.'", { '.$htmlname.': request.term }, function(data){
jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){
response( jQuery.map( data, function( item ) {
var label = item.'.$valname.'.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
return { label: label, value: item.'.$valname.', id: item.'.$htmlname.'}
var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"<strong>$1</strong>");
return { label: label, value: item.value, id: item.key}
}));
}, "json");
},