mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-16 19:23:27 +00:00
Repair NaN bug for autocomplete on counter click
This commit is contained in:
parent
dd3ad42eb5
commit
25c5a3297c
@ -45,7 +45,7 @@ $(function () {
|
||||
const code_field = $("#code_field");
|
||||
|
||||
let quantity = "";
|
||||
let search = "";
|
||||
// let search = "";
|
||||
code_field.autocomplete({
|
||||
select: function (event, ui) {
|
||||
event.preventDefault();
|
||||
@ -56,10 +56,10 @@ $(function () {
|
||||
code_field.val(quantity + ui.item.value);
|
||||
},
|
||||
source: function (request, response) {
|
||||
// by the dark magic of JS, parseInt("123abc") === 123
|
||||
quantity = parseInt(request.term);
|
||||
search = request.term.slice(quantity.toString().length)
|
||||
let matcher = new RegExp($.ui.autocomplete.escapeRegex(search), "i");
|
||||
const res = /^(\d+x)?(.*)/i.exec(request.term);
|
||||
quantity = res[1] || "";
|
||||
const search = res[2];
|
||||
const matcher = new RegExp($.ui.autocomplete.escapeRegex(search), "i" );
|
||||
response($.grep(products_autocomplete, function(value) {
|
||||
value = value.tags;
|
||||
return matcher.test( value );
|
||||
|
Loading…
Reference in New Issue
Block a user