From b281ff8af5873e907408c6a34bb71cf9a8f3bdd7 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Tue, 29 Nov 2022 15:51:22 +0100 Subject: [PATCH] Fix empty wishlist after page load --- src/assets/js/parts/wishlists.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/assets/js/parts/wishlists.js b/src/assets/js/parts/wishlists.js index 9f328b1f..7a1b9b5e 100644 --- a/src/assets/js/parts/wishlists.js +++ b/src/assets/js/parts/wishlists.js @@ -50,7 +50,7 @@ $(function () { $('.ui.dropdown.wishlists') .dropdown({ - onChange : function(wishlist_id, text, $choice) { + onChange : function(wishlist_id, text, choice) { wishthis.$_GET.id = wishlist_id; if (wishlist_id) { @@ -82,14 +82,28 @@ $(function () { urlParams.set('id', wishlist_id); updateURL(); - - /** Get wishlist cards/wishes */ + /** */ /** * Trigger priorities dropdown */ - // $('.ui.dropdown.filter.priority').api('query'); + $('.ui.dropdown.filter.priority').api('query'); + + /** + * Very dirty hack to ensure the wishes are going to be + * displayed after the page has laoded. + */ + setTimeout(function dropdown_wishlists_api() { + var api_is_complete = $('.ui.dropdown.filter.priority').api('was complete'); + + if ('' === $('.wishlist-cards').html() && api_is_complete) { + $('.ui.dropdown.filter.priority').api('query'); + + setTimeout(dropdown_wishlists_api, 1); + } + }, 1); /** */ + /* const get_wishes = new URLSearchParams( {