From caeb2fb0fbffba8bda872d7ea7588648d1fb8355 Mon Sep 17 00:00:00 2001 From: Alba Date: Thu, 24 Oct 2024 20:13:48 +0200 Subject: [PATCH] TTK-26552: Keep search text --- Resources/views/Stats/js.html.twig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Resources/views/Stats/js.html.twig b/Resources/views/Stats/js.html.twig index 5f47638..c989e35 100644 --- a/Resources/views/Stats/js.html.twig +++ b/Resources/views/Stats/js.html.twig @@ -77,6 +77,10 @@ $('.btn-stats-search-text').on('click', function(event) { event.preventDefault(); + page = 0; + var url = new URL(window.location.href); + url.searchParams.set('page', page); + window.history.pushState({}, '', url); var data = window.prepareSearch(); window.getAjaxRequest(data); }); @@ -100,7 +104,10 @@ var data = window.prepareSearch(); var page_selected = $(this).data('value'); - location.search = "?page="+page_selected; + + var url = new URL(window.location.href); + url.searchParams.set('page', page_selected); + window.history.pushState({}, '', url); {% if app.request.get('_route') == 'pumukit_stats_series_index' %} window.most_viewed_series(data['criteria'], data['from_date'], data['to_date'], page_selected); @@ -746,7 +753,7 @@ window.createPager = function(data) { var pages = Math.ceil(data.total / 10); - var active_page = data.page == 0 ? data.page : parseInt("{{ app.request.get('page')|default(0) }}"); + var active_page = data.page; var aPages = range(pages,active_page); var disabled_previous = ''; var disabled_next = '';