FIX Do not lose selected id after ENTER the TAB on autocomplete

This commit is contained in:
Laurent Destailleur
2017-10-06 10:46:45 +02:00
parent f0b314dfd7
commit 848aadb48a
2 changed files with 8 additions and 5 deletions

View File

@@ -63,10 +63,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
var autoselect = '.$autoselect.';
var options = '.json_encode($ajaxoptions).';
/* Remove product id before select another product use keyup instead of change to avoid loosing the product id. This is needed only for select of predefined product */
/* TODO Check if we can remove this */
$("input#search_'.$htmlname.'").keydown(function() {
$("#'.$htmlname.'").val("");
/* Remove selected id as soon as we type or delete a char (it means old selection is wrong). Use keyup/down instead of change to avoid loosing the product id. This is needed only for select of predefined product */
$("input#search_'.$htmlname.'").keydown(function(e) {
if (e.keyCode != 9) /* If not "Tab" key */
{
console.log("Clear id previously selected for field '.$htmlname.'");
$("#'.$htmlname.'").val("");
}
});
/* I disable this. A call to trigger is already done later into the select action of the autocomplete code