diff --git a/web/app.js b/web/app.js index e19b2b3..1983109 100644 --- a/web/app.js +++ b/web/app.js @@ -54,6 +54,12 @@ render_graphs_wrapper(); // filters checkboxes function filters_checkboxes() { fetch_list().then(function(data){ + { + const node = document.getElementById("filters_checkboxes"); + while (node.firstChild) { + node.removeChild(node.lastChild); + } + } const node = d3.select("#filters_checkboxes"); for (const itemlist of data) { var label = node.append("label"); @@ -69,14 +75,18 @@ function filters_checkboxes() { } filters_checkboxes() // listen to filters changes +var checkedBefore = getCheckedCheckboxIds('.checkbox-filters'); $(document).ready(function(){ - $('#filters').on('show.bs.dropdown', function () { - console.log("Opening dropdown"); - }); - $('#filters').on('hidden.bs.dropdown', function () { - // console.log("Dropdown hidden"); - refresh_graphs(); + const checkedAfter = getCheckedCheckboxIds('.checkbox-filters'); + if (!(checkedAfter.every(item => checkedBefore.includes(item)) && checkedBefore.every(item => checkedAfter.includes(item)))) { + refresh_graphs(); + } + checkedBefore = checkedAfter; + }); + // prevent dropdown menu from closing when clicking inside + $('#filters_checkboxes').on('click', function (e) { + e.stopPropagation(); }); });