From 0302ae93c72d27dc8f453a02d306527585f0cde5 Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Thu, 29 Dec 2016 13:00:07 -0500 Subject: [PATCH] Fixes #2534 for real, adds loadOnce setting --- RELEASE-NOTES.md | 5 ++++- src/definitions/modules/tab.js | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index cc7bd8fc4..1ad793eec 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -2,11 +2,14 @@ ### Version 2.2.8 - December 21, 2016 -**Enhancements** +**Major Enhancements** - **Icons** - Updates Font Awesome to `4.7.0` **Always the man @BreadMaker** #4766 - **Dropdown** - Added new setting `filterAPIResults` which when enabled will filter results locally by query after API returns, allowing your API call to return the full dropdown dataset. **Thanks @enix223** #4815 +- **Tab** - Added setting `loadOnce`, which when enabled only calls remote endpoint for tab data on first load #2534 +**Enhancements** + **Critical Bugs** - **Dropdown** - `forceSelection` will no longer select value in `multiple selection dropdown` #4041 #4516 diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index 2647541a1..383a8d561 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -476,7 +476,10 @@ $.fn.tab = function(parameters) { settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent); settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent); - if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) { + if(settings.loadOnce) { + module.cache.add(fullTabPath, true); + } + else if(typeof settings.cacheType == 'string' && settings.cacheType.toLowerCase() == 'dom' && $tab.children().length > 0) { setTimeout(function() { var $clone = $tab.children().clone(true) @@ -506,11 +509,13 @@ $.fn.tab = function(parameters) { if(settings.cache && cachedContent) { module.activate.tab(tabPath); module.debug('Adding cached content', fullTabPath); - if(settings.evaluateScripts == 'once') { - module.update.content(tabPath, cachedContent, false); - } - else { - module.update.content(tabPath, cachedContent); + if(!settings.loadOnce) { + if(settings.evaluateScripts == 'once') { + module.update.content(tabPath, cachedContent, false); + } + else { + module.update.content(tabPath, cachedContent); + } } settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent); } @@ -898,6 +903,7 @@ $.fn.tab.settings = { alwaysRefresh : false, // load tab content new every tab click cache : true, // cache the content requests to pull locally + loadOnce : false, // Whether tab data should only be loaded once when using remote content cacheType : 'response', // Whether to cache exact response, or to html cache contents after scripts execute ignoreFirstLoad : false, // don't load remote content on first load