継承したJavaScriptがあります。タブスイッチャーとして使用されています。残念ながら、それは機能していません。コードは次のとおりです。
$(document).ready(function(){
/* This is the back button friendly tab switcher */
var trackContainers = $('.switcher > .results');
trackContainers.hide().filter(':first').show();
$(window).bind('hashchange', function () {
var hash = window.location.hash || '#dpp';
console.log('hash: ' + hash);
trackContainers.hide();
trackContainers.filter(hash).show();
$('ul.tabs li').removeClass('active');
$('a[hash='+hash+']').parent().addClass('active');
});
$(window).trigger("hashchange").location(hash);
});
特定のタブがクリックされると、クリックされたタブを囲むliタグのクラスが変更されます。タブコードは次のようになります。
<div class="switcher">
<ul class="tabs">
<li class="inactive"><a href="#dpp">Digital Path to Purchase</a></li>
<li class="inactive"><a href="#cre">Fueling Creativity</a></li>
<li class="inactive"><a href="#bpp">Best Practices/Big Picture</a></li>
<li class="inactive"><a href="#si">Shopper Insights 101</a></li>
<li class="inactive"><a href="#dem">Who Is Your Shopper</a></li>
<li class="inactive"><a href="#gt">Google Theater</a></li>
<li class="inactive"><a href="#res">Understanding the Shopper</a></li>
<li class="inactive"><a href="#bar">Brand Activation at Retail</a></li>
<li class="active"><a href="#duc">Deeper Understanding of Center Store</a></li>
</ul>
</div>
</div>
#ducというリンクのliアイテムにアクティブなクラスがあることがわかります。ただし、Firebugのスクリプトコードを見ると、ハッシュが定義されていないというエラーが表示されます。
繰り返しますが、Firebugを調べますが、今回はコンソールタブを見ると、ハッシュが定義されていることが非常に明確に示されています。
console.logと.trigger行の間の定義がどのように失われているのか誰かが指摘できますか?