$('.filter-option').on('change', function() {
    const $this = $(this);
    const filterKey = $this.data('filterName');
    const filterVal = $this.data('filterValue');
    const addingFilter = $this.prop('checked');

    if ( addingFilter ) {
        let newFilter = {};
        newFilter[filterKey] = filterVal;
        window.location = baseRef + '?filter=' + encodeURIComponent(JSON.stringify(newFilter));
    } else window.location = baseRef + '?remove=' + filterKey;
});

$('#pageLen').on('change', function() {
    $('#pageLengthForm').submit();
});

$('#pageLen2').on('change', function() {
    $('#pageLengthForm2').submit();
});

// $('.pageLen').on('change', function() {
//     $(this).parent('form').submit();
// });