From 36627a9e7e0e1be0fba0e2a7b866378f512c64d9 Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Sun, 9 Sep 2018 11:15:37 +0000 Subject: [PATCH 6/7] load remote tab only once --- public/javascripts/application.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ecb0d6e..cd0b0b9 100755 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -377,21 +377,26 @@ function showIssueHistory(journal, url) { return false; } -function getRemoteTab(name, remote_url, url) { - $('#tab-content-' + name).parent().find('.tab-content').hide(); - $('#tab-content-' + name).parent().find('div.tabs a').removeClass('selected'); - $('#tab-' + name).addClass('selected') +function getRemoteTab(name, remote_url, url, load_always = false) { + var tab_content = $('#tab-content-' + name); - replaceInHistory(url) + tab_content.parent().find('.tab-content').hide(); + tab_content.parent().find('div.tabs a').removeClass('selected'); + $('#tab-' + name).addClass('selected'); - $.ajax({ - url: remote_url, - type: 'get', - success: function(data){ - $('#tab-content-' + name).html(data).show(); - } - }); + replaceInHistory(url); + if (tab_content.children().length == 0 && load_always == false) { + $.ajax({ + url: remote_url, + type: 'get', + success: function(data){ + tab_content.html(data) + } + }); + } + + tab_content.show(); return false; } -- 2.1.4