diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 9030dd6e749690f489a690d2c5a37ebd8e8aea85..901eee60cc5121d3627b958edadbe53d07e093e8 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -567,8 +567,8 @@ class AjaxController extends AbstractBase $checked[$selector] = true; $data = $user->getSavedData($id, null, $source); + $result[$selector] = []; if ($data && count($data) > 0) { - $result[$selector] = []; // if this item was saved, add it to the list of saved items. foreach ($data as $list) { $result[$selector][] = [ diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js index 3a75ae5d08403f2a3c5b09a9e93c3c922b4846f1..7e41a81748edc1f9e34dc9e2bb07b7d9683aaa33 100644 --- a/themes/bootstrap3/js/check_save_statuses.js +++ b/themes/bootstrap3/js/check_save_statuses.js @@ -3,13 +3,18 @@ function displaySaveStatus(itemLists, $item) { if (itemLists.length > 0) { + // If we got lists back, display them! var html = '<ul>' + itemLists.map(function convertToLi(l) { return '<li><a href="' + l.list_url + '">' + htmlEncode(l.list_title) + '</a></li>'; }).join('') + '</ul>'; - $item.removeClass('js-save-pending'); $item.find('.savedLists').addClass('loaded'); $item.find('.js-load').replaceWith(html); + } else { + // If we got nothing back, remove the pending status: + $item.find('.js-load').remove(); } + // No matter what, clear the flag that we have a pending save: + $item.removeClass('js-save-pending'); } function saveStatusFail(response, textStatus) {