From 47584dd8451a60bcb7d1c0aba06caa4972cc35db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 6 Feb 2023 00:52:46 +0100 Subject: [PATCH] Automatically select the first option of part multi select. --- assets/controllers/elements/datatables/parts_controller.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/controllers/elements/datatables/parts_controller.js b/assets/controllers/elements/datatables/parts_controller.js index 3c6737ac..33362648 100644 --- a/assets/controllers/elements/datatables/parts_controller.js +++ b/assets/controllers/elements/datatables/parts_controller.js @@ -76,6 +76,11 @@ export default class extends DatatablesController { tom_select.addOptions(json, false); + //Select first element if there is one (so category select is not empty) + if(json.length > 0) { + tom_select.setValue(json[0].value); + } + select_element.nextElementSibling.classList.remove('d-none'); //$(select_element).selectpicker('show');