From 12628450a24a95edbffd7cc620090c6b04942911 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 14 Feb 2017 17:00:38 +0200
Subject: [PATCH] =?UTF-8?q?Use=20the=20.always=20method=20to=20handle=20re?=
 =?UTF-8?q?cord=20tab=20ajax=20loading=20so=20that=20also=E2=80=A6=20(#916?=
 =?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Use the .always method to handle record tab ajax loading so that also tabs that fail to load properly are displayed.

* Fixed a code style issue.
---
 themes/bootstrap3/js/record.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js
index 63900a8571f..45d7e378026 100644
--- a/themes/bootstrap3/js/record.js
+++ b/themes/bootstrap3/js/record.js
@@ -181,8 +181,12 @@ function ajaxLoadTab($newTab, tabid, setHash) {
     type: 'POST',
     data: {tab: tabid}
   })
-  .done(function ajaxLoadTabDone(data) {
-    $newTab.html(data);
+  .always(function ajaxLoadTabDone(data) {
+    if (typeof data === 'object') {
+      $newTab.html(data.responseText ? data.responseText : VuFind.translate('error_occurred'));
+    } else {
+      $newTab.html(data);
+    }
     registerTabEvents();
     if (typeof syn_get_widget === "function") {
       syn_get_widget();
-- 
GitLab