これが私が取り組んでいるサイトです:http://cirkut.net/sub/northwood/popunder/
基本的に私がやろうとしているのは、ドロップダウンにカーソルを合わせた後、側面にある4つのリンクをクリックすると、選択した内容に基づいてコンテンツが変更されます。私のフィルタリングは初期ロードで機能しますが、クリックした後、たとえばLocations
、中央と右のコンテンツ列に何も伝播しません。
これまでのキーアップのコードは次のとおりです。
$('.megaMenu .menuSearchBar').on("keyup",function(event){
//NONE OF THIS FIRES AFTER SELECTING a MENU ITEM
var activeitem = $('.leftmenu a.active').text();
activeitem = activeitem.toLowerCase();
activeitem = activeitem.split(' ').join('-');
data = null;
//Switch to determine which data to use during filtering
switch(activeitem){
case 'programs':
data = programs;
break;
case 'locations':
data = locations;
break;
case 'financial-aid':
data = financialaid;
break;
case 'admissions':
data = admissions;
break;
}
var typedtext = $(this).val();
var matching = new Array();
for(index in data){
for(i in data[index]){
if(data[index][i].toLowerCase().indexOf(typedtext.toLowerCase()) != -1){
matching.push(data[index][0]);
break;
}
}
}
//Filtering code goes here, just know that it outputs
//into the middle and right columns
});
$('.megaMenu .menuSearchBar').keyup(); //Propagate initial content in middle and left column
アイテムを切り替えるために<div>
、メニューアイテムをクリックするとすべてが変わる4つの検索列(左側のコンテンツ)を保持する非表示があります。メニュー項目がクリックされたときのコードは次のとおりです。
$('.leftmenu a').click(function(){
var oldactive = active;
$('.leftmenu a').removeClass('active');
$(this).addClass('active');
//Get the new active item and set it so it can be compared in the switch above
var active = $('.leftmenu').find('.active').text();
active = active.toLowerCase();
active = active.split(' ').join('-');
//Change the left content to the search bar correlating to item clicked
$('.superNav .left').html($('.hidden .'+active).html());
//Clear out the middle and right content for new data
$('.middle').html('');
$('.right').html('');
//Supposed to trigger the above .on() call to set the new content, but doesn't.
$('.megaMenu .menuSearchBar').keyup();
});
サイドメニュー項目をクリックしなくても、on keyup
機能は完全に機能します。
関数が正しく起動しなくなったため、私の問題はleft
クリックの範囲内にあるはずです。keyup
何か案は?