From 70fe470fdd5e84f6b478e2d169c99ea77223bea9 Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 18 Sep 2014 11:10:29 -0400 Subject: [PATCH] Add support for in-page anchor links while using anchor link history --- src/definitions/modules/tab.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index d49685679..74e237209 100755 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -258,6 +258,7 @@ $.tab = $.fn.tab = function(parameters) { isLastIndex = (index + 1 == pathArray.length), $tab = module.get.tabElement(currentPath), + $anchor, nextPathArray, nextPath, isLastTab @@ -308,7 +309,20 @@ $.tab = $.fn.tab = function(parameters) { } } else { - if(!settings.history) { + // look for in page anchor + $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'); + currentPath = $anchor.closest('[data-tab]').data('tab'); + + if($anchor.size() > 0 && currentPath) { + module.debug('No tab found, but deep anchor link present, opening parent tab'); + module.activate.all(currentPath); + if( !module.cache.read(currentPath) ) { + module.cache.add(currentPath, true); + module.debug('First time tab loaded calling tab init'); + $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + } + } + else { module.error(error.missingTab, $module, currentPath); } return false;