Browse Source

Add support for in-page anchor links while using anchor link history

pull/1129/head
jlukic 10 years ago
parent
commit
70fe470fdd
1 changed files with 15 additions and 1 deletions
  1. 16
      src/definitions/modules/tab.js

16
src/definitions/modules/tab.js

@ -258,6 +258,7 @@ $.tab = $.fn.tab = function(parameters) {
isLastIndex = (index + 1 == pathArray.length), isLastIndex = (index + 1 == pathArray.length),
$tab = module.get.tabElement(currentPath), $tab = module.get.tabElement(currentPath),
$anchor,
nextPathArray, nextPathArray,
nextPath, nextPath,
isLastTab isLastTab
@ -308,7 +309,20 @@ $.tab = $.fn.tab = function(parameters) {
} }
} }
else { 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); module.error(error.missingTab, $module, currentPath);
} }
return false; return false;

Loading…
Cancel
Save