From 25c5ed8f7232d96d020898580bda8c2e050e74f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 28 Jul 2017 18:09:38 +0200 Subject: [PATCH] Fix for compatibility --- htdocs/core/lib/ajax.lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 705bcf6deab..76a1458b913 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -46,6 +46,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt { if (empty($minLength)) $minLength=1; + $dataforrenderITem='ui-autocomplete'; + $dataforitem='ui-autocomplete-item'; + // Allow two constant to use other values for backward compatibility + if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); + if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM'); + // Input search_htmlname is original field // Input htmlname is a second input field used when using ajax autocomplete. $script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />'; @@ -185,10 +191,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code. } ,delay: 500 - }).data("ui-autocomplete")._renderItem = function( ul, item ) { + }).data("'.$dataforrenderITem.'")._renderItem = function( ul, item ) { return $("<li>") - .data( "ui-autocomplete-item", item ) // jQuery UI > 1.10.0 + .data( "'.$dataforitem.'", item ) // jQuery UI > 1.10.0 .append( \'<a><span class="tag">\' + item.label + "</span></a>" ) .appendTo(ul); }; -- GitLab