diff --git a/aleksis/core/static/js/multi_select.js b/aleksis/core/static/js/multi_select.js index e612f6eae7df26d79e5b4cf6efccfb65f213ed66..cddf911b5f50be2217075d2c0f34191adab6f72e 100644 --- a/aleksis/core/static/js/multi_select.js +++ b/aleksis/core/static/js/multi_select.js @@ -1,17 +1,16 @@ $(document).ready(function () { - $("#select_all_container").show(); - $("#header_box").change(function () { + $(".select--header-box").change(function () { /* If the top checkbox is checked, all sub checkboxes should be checked, if it gets unchecked, all other ones should get unchecked. */ if ($(this).is(":checked")) { - $(document).find('input[name="selected_objects"]').prop({ + $(this).closest("table").find('input[name="selected_objects"]').prop({ indeterminate: false, checked: true, }); } else { - $(document).find('input[name="selected_objects"]').prop({ + $(this).closest("table").find('input[name="selected_objects"]').prop({ indeterminate: false, checked: false, }); @@ -27,10 +26,11 @@ $(document).ready(function () { */ let checked = $(this).is(":checked"); let indeterminate = false; - $(document).find('input[name="selected_objects"]').each(function () { + let table = $(this).closest("table"); + table.find('input[name="selected_objects"]').each(function () { if ($(this).is(":checked") !== checked) { /* Set the header box to indeterminate if the boxes are not the same */ - $("#header_box").prop({ + table.find(".select--header-box").prop({ indeterminate: true, }) indeterminate = true; @@ -39,7 +39,7 @@ $(document).ready(function () { }); if (!(indeterminate)) { /* All boxes are the same, set the header box to the same value */ - $("#header_box").prop({ + table.find(".select--header-box").prop({ indeterminate: false, checked: checked, }); diff --git a/aleksis/core/util/tables.py b/aleksis/core/util/tables.py index 50a27a52bc4e5025375ee6189506efce7e151e7d..8bb9fd5c0b4212a1361ebd12b6acd5087731ca58 100644 --- a/aleksis/core/util/tables.py +++ b/aleksis/core/util/tables.py @@ -40,7 +40,7 @@ class SelectColumn(MaterializeCheckboxColumn): def __init__(self, *args, **kwargs): kwargs["attrs"] = { "td__input": {"name": "selected_objects"}, - "th__input": {"id": "header_box"}, + "th__input": {"class": "select--header-box"}, } kwargs.setdefault("accessor", A("pk")) super().__init__(*args, **kwargs)