From 0b9edd1eda44b5b7714f251848754254db974e7d Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 12 Feb 2015 12:40:56 -0500 Subject: [PATCH] #1784 Updates Tab remote API syntax with changes in 1.x --- src/definitions/modules/tab.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index 193f573a0..9af6746ef 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -77,7 +77,7 @@ $.fn.tab = function(parameters) { if(settings.auto) { module.verbose('Setting up automatic tab retrieval from server'); settings.apiSettings = { - url: settings.path + '/{$tab}' + url: (settings.path || '') + '/{$tab}' }; } @@ -270,10 +270,10 @@ $.fn.tab = function(parameters) { ; module.verbose('Looking for tab', tab); if(isTab) { - module.verbose('Tab was found', tab); + module.verbose('Tab was found', tab); // scope up - activeTabPath = currentPath; + activeTabPath = currentPath; parameterArray = module.utilities.filterArray(pathArray, currentPathArray); if(isLastIndex) { @@ -341,11 +341,11 @@ $.fn.tab = function(parameters) { fetch: function(tabPath, fullTabPath) { var - $tab = module.get.tabElement(tabPath), - apiSettings = { - dataType : 'html', - stateContext : $tab, - onSuccess : function(response) { + $tab = module.get.tabElement(tabPath), + apiSettings = { + dataType : 'html', + on : 'now', + onSuccess : function(response) { module.cache.add(fullTabPath, response); module.content.update(tabPath, response); if(tabPath == activeTabPath) { @@ -360,7 +360,7 @@ $.fn.tab = function(parameters) { }, urlData: { tab: fullTabPath } }, - request = $tab.data(metadata.promise) || false, + request = $tab.api('get request') || false, existingRequest = ( request && request.state() === 'pending' ), requestSettings, cachedContent @@ -369,6 +369,7 @@ $.fn.tab = function(parameters) { fullTabPath = fullTabPath || tabPath; cachedContent = module.cache.read(fullTabPath); + if(settings.cache && cachedContent) { module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); @@ -384,7 +385,8 @@ $.fn.tab = function(parameters) { else if($.api !== undefined) { requestSettings = $.extend(true, { headers: { 'X-Remote': true } }, settings.apiSettings, apiSettings); module.debug('Retrieving remote content', fullTabPath, requestSettings); - $.api( requestSettings ); + console.log(existingRequest, requestSettings, cachedContent); + $tab.api( requestSettings ); } else { module.error(error.api);