diff options
-rw-r--r-- | public/javascripts/application.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a222807..7b8717a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -199,12 +199,21 @@ $(document).ready(function() { if ($(this).parent().hasClass("off")) { // User clicked something else var tabBar = $(this).parents(".tab-bar"); + var url = $(this).attr("href") + var cacheKey = "cached_" + url; tabBar.addClass("waiting"); - jQuery.ajax({ - url: $(this).attr("href"), - type: "get", - success: function (d,t) {onComplete(d, tabBar)} - }); + if (cachedData = tabBar.data(cacheKey)) { + onComplete(cachedData, tabBar) + } else { + jQuery.ajax({ + url: url, + type: "get", + success: function (d,t) { + tabBar.data(cacheKey, d); + onComplete(d, tabBar) + } + }); + } } return false; }); |