ここに私が取り組んでいるもののスクリーンショットがあります:
想定される動作:デフォルトでは、ソーシャル フィードは Twitter ストリームに設定されています。ユーザーがツールバーから他のストリームをクリックすると、下のコンテンツが他のコンテンツに切り替わります。表示されているものを切り替える方法がよくわかりません。
これが私のjQueryです:
$(function() {
// Sets the default stream to Twitter and selects it in the toolar
$("#feedFilter li").first().addClass("selected");
$("#socialFeed .twitterFeed").show();
$("#feedFilter li").click(function() {
// Clears the white background on the toolbar selection
$(this).parent().find("li").removeClass("selected");
// Toggles the white background on the toolbar selection
$(this).toggleClass("selected");
// Clears out all socialFeed lists
$("#socialFeed").fadeOut();
// Gets the index of the stream selected in the toolbar and shows the stream
var x = $(this).index();
switch(x) {
case 0: $("#socialFeed .twitterFeed").fadeIn(); break;
case 1: $("#socialFeed .facebookFeed").fadeIn(); break;
case 2: $("#socialFeed .newsFeed").fadeIn(); break;
case 3: $("#socialFeed .linkedInFeed").fadeIn(); break;
}
});
階層を確認できるように、ここに私のコードを示します。
[...]
<div class="containerSubHeader">
<ul id="feedFilter">
<li>Twitter</li>
<li>Facebook</li>
<li>Google News</li>
<li>LinkedIn</li>
</ul>
</div>
<div class="mainContainer grad-lt-grey">
<ul id="socialFeed" class="twitterFeed">
<?php
[Gets the Twitter content here and puts in <li> items]
?>
</ul>
<ul id="socialFeed" class="facebookFeed">
<?php
[Gets the Facebook content here and puts in <li> items]
?>
</ul>
<ul id="socialFeed" class="newsFeed">
<?php
[Gets the Google News content here and puts in <li> items]
?>
</ul>
<ul id="socialFeed" class="linkedInFeed">
<?php
[Gets the LinkedIn content here and puts in <li> items]
?>
</ul>
</div>
[...]
これは機能していませんが、私の問題が何であるかわかりません。代わりにそれを行うより良い方法はありますか?jQuery を使用して正しい PHP を順不同のリスト タグに追加するだけですが、それは面倒になり、これは「簡単」に思えました (またはそう思った)。
何か助けはありますか?