From c9edac9cd61e670c9fec68c8c33d24b332be0283 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Nov 2012 13:33:18 +0100 Subject: [PATCH] Try to fix differently pb of change/keyup because current change has a regression (no way to use ajax select onto supplier orders when using keybord or mouse selection). --- 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 824d326883d..4b5b4f986ce 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -49,8 +49,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt // Remove product id before select another product // use keyup instead change to avoid loosing the product id - $("input#search_'.$htmlname.'").keyup(function() { - $("#'.$htmlname.'").val("").trigger("change"); + $("input#search_'.$htmlname.'").keydown(function() { + //console.log(\'purge_id_after_keydown\'); + $("#'.$htmlname.'").val(""); + }); + $("input#search_'.$htmlname.'").change(function() { + //console.log(\'keyup\'); + $("#'.$htmlname.'").trigger("change"); }); // Check when keyup $("input#search_'.$htmlname.'").onDelayedKeyup({ handler: function() { @@ -116,6 +121,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt dataType: "json", minLength: '.$minLength.', select: function( event, ui ) { + //console.log(\'set value of id with \'+ui.item.id); $("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Disable an element if (options.option_disabled) {