diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index edcfa676c881eaec837ae0a378c3bf8e51a3c862..181f6c52f4add27f11ae503a0c26fb27f26e4a04 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -501,11 +501,15 @@ class AjaxController extends AbstractBase $source = isset($sources[$i]) ? $sources[$i] : DEFAULT_SEARCH_BACKEND; $data = $user->getSavedData($id, null, $source); if ($data && count($data) > 0) { - $result[$i] = []; + $selector = $source . '|' . $id; + $result[$selector] = []; // if this item was saved, add it to the list of saved items. foreach ($data as $list) { - $result[$i][] = [ - 'list_id' => $list->list_id, + $result[$selector][] = [ + 'list_url' => $this->url()->fromRoute( + 'userList', + ['id' => $list->list_id] + ), 'list_title' => $list->list_title ]; } diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js index 66556d4d88c2a4d7e3ff294537c1e95f504b74fe..1cf43788fd69cc31d35aca939209e731ac94e1e8 100644 --- a/themes/bootstrap3/js/check_save_statuses.js +++ b/themes/bootstrap3/js/check_save_statuses.js @@ -1,11 +1,14 @@ /*global VuFind */ function checkSaveStatuses() { + var elements = {} var data = $.map($('.result,.record'), function(record) { if($(record).find('.hiddenId').length == 0 || $(record).find('.hiddenSource').length == 0) { return false; } - return {'id':$(record).find('.hiddenId').val(), 'source':$(record).find('.hiddenSource')[0].value}; + var datum = {'id':$(record).find('.hiddenId').val(), 'source':$(record).find('.hiddenSource')[0].value}; + elements[datum.source+"|"+datum.id] = $(record).find('.savedLists'); + return datum; }); if (data.length) { var ids = []; @@ -21,15 +24,15 @@ function checkSaveStatuses() { data: {id:ids, 'source':srcs} }) .done(function(response) { - for (var rn in response.data) { - var list = $('#result'+rn).find('.savedLists'); - if (list.length == 0) { + for (var sel in response.data) { + var list = elements[sel]; + if (!list) { list = $('.savedLists'); } var html = list.find('strong')[0].outerHTML+'<ul>'; - for (var i=0; i<response.data[rn].length; i++) { - html += '<li><a href="' + VuFind.getPath() + '/MyResearch/MyList/' + response.data[rn][i].list_id + '">' - + response.data[rn][i].list_title + '</a></li>'; + for (var i=0; i<response.data[sel].length; i++) { + html += '<li><a href="' + response.data[sel][i].list_url + '">' + + response.data[sel][i].list_title + '</a></li>'; } html += '</ul>'; list.html(html).removeClass('hidden');