Fixed autofocus on barcode input
This commit is contained in:
parent
1c056d85ef
commit
3bed47458f
2 changed files with 13 additions and 2 deletions
|
|
@ -41,6 +41,17 @@ async function loadCash(price) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function indexOnLoad(){
|
||||||
|
loadProducts();
|
||||||
|
document.querySelector("input[autofocus]").addEventListener("blur", function() {
|
||||||
|
var t = this;
|
||||||
|
t.focus();
|
||||||
|
setTimeout(function() { // Some browsers won't let you do it until
|
||||||
|
t.focus(); // after the blur has completed
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function loadProducts() {
|
async function loadProducts() {
|
||||||
const loadProductRequest = new Request(api_url + "/products")
|
const loadProductRequest = new Request(api_url + "/products")
|
||||||
all_products = await makeAPIRequest(loadProductRequest)
|
all_products = await makeAPIRequest(loadProductRequest)
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
<link rel="stylesheet" href="{{url_for('static', filename='style/main.css')}}">
|
<link rel="stylesheet" href="{{url_for('static', filename='style/main.css')}}">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="loadProducts()">
|
<body onload="indexOnLoad()">
|
||||||
<form action="" id="barcode_form">
|
<form action="" id="barcode_form">
|
||||||
<input id="barcode_input" type="text" onblur="this.focus()" autofocus>
|
<input id="barcode_input" type="text" autofocus>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue