From 0ff8655fb351f937e272a0ed25f41cf72b7e5d83 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 15 Jan 2021 12:12:55 +0100 Subject: [PATCH] chg: [element:generic_index] Usage of UI factory for group_search --- .../ListTopBar/group_search.php | 20 +++++++++++++------ webroot/js/main.js | 10 +--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/templates/element/genericElements/ListTopBar/group_search.php b/templates/element/genericElements/ListTopBar/group_search.php index 6387bef..df93ee9 100644 --- a/templates/element/genericElements/ListTopBar/group_search.php +++ b/templates/element/genericElements/ListTopBar/group_search.php @@ -53,15 +53,23 @@ } ?> var randomValue = ''; - $('#quickFilterButton-' + randomValue).click(function() { - var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-').val()); - executePagination(randomValue, url); + $(`#quickFilterButton-${randomValue}`).click(() => { + doFilter($(this)) }); - $('#quickFilterField-' + randomValue).on('keypress', function (e) { + $(`#quickFilterField-${randomValue}`).on('keypress', (e) => { if(e.which === 13) { - var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-').val()); - executePagination(randomValue, url); + const $button = $(this).parent().find(`#quickFilterButton-${randomValue}`) + doFilter($button) } }); + + function doFilter($button) { + const encodedFilters = encodeURIComponent($(`#quickFilterField-${randomValue}`).val()) + const url = `/${controller}/${action}${additionalUrlParams}?quickFilter=${encodedFilters}` + UI.reload(url, $(`#table-container-${randomValue}`), $(`#table-container-${randomValue} table.table`), [{ + node: $button, + config: {} + }]) + } }); diff --git a/webroot/js/main.js b/webroot/js/main.js index 333074c..3e05d3a 100644 --- a/webroot/js/main.js +++ b/webroot/js/main.js @@ -1,13 +1,5 @@ function executePagination(randomValue, url) { - var target = '#table-container-' + randomValue - $.ajax({ - dataType:"html", - cache: false, - success:function (data, textStatus) { - $(target).html(data); - }, - url:url, - }); + UI.reload(url, $(`#table-container-${randomValue}`), $(`#table-container-${randomValue} table.table`)) } function executeStateDependencyChecks(dependenceSourceSelector) {