From 0461d1c01998a9d0c62c023760c7d3d34229f97c Mon Sep 17 00:00:00 2001 From: Tim Kung Date: Wed, 24 Aug 2016 09:05:02 +1200 Subject: [PATCH] Updating TabSet.js to open tabs correctly on page load when hash is added to URL --- javascript/TabSet.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/javascript/TabSet.js b/javascript/TabSet.js index b1c0e4902..d42d4e241 100644 --- a/javascript/TabSet.js +++ b/javascript/TabSet.js @@ -1,5 +1,5 @@ -(function($){ - $.entwine('ss', function($){ +(function($) { + $.entwine('ss', function($) { /** * Lightweight wrapper around jQuery UI tabs for generic tab set-up */ @@ -34,11 +34,11 @@ * @param {string} hash * @desc Allows linking to a specific tab. */ - openTabFromURL: function (hash) { + openTabFromURL: function(hash) { var $trigger; // Make sure the hash relates to a valid tab. - $.each(this.find('.cms-panel-link'), function () { + $.each(this.find('.ui-tabs-anchor'), function() { // The hash in in the button's href and there is exactly one tab with that id. if (this.href.indexOf(hash) !== -1 && $(hash).length === 1) { $trigger = $(this); @@ -52,7 +52,7 @@ } // Switch to the correct tab when AJAX loading completes. - $(window).one('ajaxComplete', function () { + $(document).ready(function() { $trigger.click(); }); }, @@ -66,7 +66,7 @@ if (!$(this).attr('href')) return; var matches = $(this).attr('href').match(/#.*/); - if(!matches) return; + if (!matches) return; $(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]); }); }