可以指定一个Div New这个Menu
然后Menu.show
可是当我的Div里面的内容改变了
我怎么样让菜单重新获取内容并且显示呢?或者给个其他的例子我发现用下面这种数据结构可以重画菜单
可是我自己构造不出这样的结构(javascript太菜了)
请问大虾们我要循环构造下面的这个数组怎么写啊?
不知道我说清楚了不?
var aItems = [
{ text: "Communication", submenu: { id: "communication", itemdata: [
{ text: "360", url: "http://360.yahoo.com" },
{ text: "Alerts", url: "http://alerts.yahoo.com" },
{ text: "Avatars", url: "http://avatars.yahoo.com" },
{ text: "Groups", url: "http://groups.yahoo.com " },
{ text: "Internet Access", url: "http://promo.yahoo.com/broadband" },
{ text: "PIM", submenu: { id: "pim", itemdata: [ { text: "Yahoo! Mail", url:"http://mail.yahoo.com" },
{ text: "Yahoo! Address Book", url:"http://addressbook.yahoo.com" },
{ text: "Yahoo! Calendar", url:"http://calendar.yahoo.com" },
{ text: "Yahoo! Notepad", url:"http://notepad.yahoo.com" } ] }
},
{ text: "Member Directory", url: "http://members.yahoo.com" },
{ text: "Messenger", url: "http://messenger.yahoo.com" },
{ text: "Mobile", url: "http://mobile.yahoo.com" },
{ text: "Photos", url: "http://photos.yahoo.com" },
] } }, { text: "Shopping", submenu: { id: "shopping", itemdata: [ { text: "Auctions", url: "http://auctions.shopping.yahoo.com" },
{ text: "Autos", url: "http://autos.yahoo.com" },
{ text: "Classifieds", url: "http://classifieds.yahoo.com" },
{ text: "Flowers & Gifts", url: "http://shopping.yahoo.com/b:Flowers%20%26%20Gifts:20146735" },
{ text: "Points", url: "http://points.yahoo.com" },
{ text: "Real Estate", url: "http://realestate.yahoo.com" },
{ text: "Travel", url: "http://travel.yahoo.com" },
{ text: "Wallet", url: "http://wallet.yahoo.com" },
{ text: "Yellow Pages", url: "http://yp.yahoo.com" }
] } }, { text: "Entertainment", submenu: { id: "entertainment", itemdata: [
{ text: "Fantasy Sports", url: "http://fantasysports.yahoo.com" },
{ text: "Games", url: "http://games.yahoo.com" },
{ text: "Kids", url: "http://www.yahooligans.com" },
{ text: "Music", url: "http://music.yahoo.com" },
{ text: "Movies", url: "http://movies.yahoo.com" },
{ text: "Radio", url: "http://music.yahoo.com/launchcast" },
{ text: "Travel", url: "http://travel.yahoo.com" },
{ text: "TV", url: "http://tv.yahoo.com" }
] } }, { text: "Information", submenu: { id: "information", itemdata: [
{ text: "Downloads", url: "http://downloads.yahoo.com" },
{ text: "Finance", url: "http://finance.yahoo.com" },
{ text: "Health", url: "http://health.yahoo.com" },
{ text: "Local", url: "http://local.yahoo.com" },
{ text: "Maps & Directions", url: "http://maps.yahoo.com" },
{ text: "My Yahoo!", url: "http://my.yahoo.com" },
{ text: "News", url: "http://news.yahoo.com" },
{ text: "Search", url: "http://search.yahoo.com" },
{ text: "Small Business", url: "http://smallbusiness.yahoo.com" },
{ text: "Weather", url: "http://weather.yahoo.com" }
] } } ];
然后Menu.show
可是当我的Div里面的内容改变了
我怎么样让菜单重新获取内容并且显示呢?或者给个其他的例子我发现用下面这种数据结构可以重画菜单
可是我自己构造不出这样的结构(javascript太菜了)
请问大虾们我要循环构造下面的这个数组怎么写啊?
不知道我说清楚了不?
var aItems = [
{ text: "Communication", submenu: { id: "communication", itemdata: [
{ text: "360", url: "http://360.yahoo.com" },
{ text: "Alerts", url: "http://alerts.yahoo.com" },
{ text: "Avatars", url: "http://avatars.yahoo.com" },
{ text: "Groups", url: "http://groups.yahoo.com " },
{ text: "Internet Access", url: "http://promo.yahoo.com/broadband" },
{ text: "PIM", submenu: { id: "pim", itemdata: [ { text: "Yahoo! Mail", url:"http://mail.yahoo.com" },
{ text: "Yahoo! Address Book", url:"http://addressbook.yahoo.com" },
{ text: "Yahoo! Calendar", url:"http://calendar.yahoo.com" },
{ text: "Yahoo! Notepad", url:"http://notepad.yahoo.com" } ] }
},
{ text: "Member Directory", url: "http://members.yahoo.com" },
{ text: "Messenger", url: "http://messenger.yahoo.com" },
{ text: "Mobile", url: "http://mobile.yahoo.com" },
{ text: "Photos", url: "http://photos.yahoo.com" },
] } }, { text: "Shopping", submenu: { id: "shopping", itemdata: [ { text: "Auctions", url: "http://auctions.shopping.yahoo.com" },
{ text: "Autos", url: "http://autos.yahoo.com" },
{ text: "Classifieds", url: "http://classifieds.yahoo.com" },
{ text: "Flowers & Gifts", url: "http://shopping.yahoo.com/b:Flowers%20%26%20Gifts:20146735" },
{ text: "Points", url: "http://points.yahoo.com" },
{ text: "Real Estate", url: "http://realestate.yahoo.com" },
{ text: "Travel", url: "http://travel.yahoo.com" },
{ text: "Wallet", url: "http://wallet.yahoo.com" },
{ text: "Yellow Pages", url: "http://yp.yahoo.com" }
] } }, { text: "Entertainment", submenu: { id: "entertainment", itemdata: [
{ text: "Fantasy Sports", url: "http://fantasysports.yahoo.com" },
{ text: "Games", url: "http://games.yahoo.com" },
{ text: "Kids", url: "http://www.yahooligans.com" },
{ text: "Music", url: "http://music.yahoo.com" },
{ text: "Movies", url: "http://movies.yahoo.com" },
{ text: "Radio", url: "http://music.yahoo.com/launchcast" },
{ text: "Travel", url: "http://travel.yahoo.com" },
{ text: "TV", url: "http://tv.yahoo.com" }
] } }, { text: "Information", submenu: { id: "information", itemdata: [
{ text: "Downloads", url: "http://downloads.yahoo.com" },
{ text: "Finance", url: "http://finance.yahoo.com" },
{ text: "Health", url: "http://health.yahoo.com" },
{ text: "Local", url: "http://local.yahoo.com" },
{ text: "Maps & Directions", url: "http://maps.yahoo.com" },
{ text: "My Yahoo!", url: "http://my.yahoo.com" },
{ text: "News", url: "http://news.yahoo.com" },
{ text: "Search", url: "http://search.yahoo.com" },
{ text: "Small Business", url: "http://smallbusiness.yahoo.com" },
{ text: "Weather", url: "http://weather.yahoo.com" }
] } } ];
我只是想解释清楚我构造的意思
var menuItems = new Array();
var menuItem;
var menus = new Array();
var menu;
for(var i=0;i<columns.length;i++)
{
if(columns[i].selectSingleNode("visible").text == "none")
{
//alert("one more");
menuItem = {text:"",url:""};
//alert("1");
menuItem.text = columns[i].selectSingleNode("columnValue").text;
menuItem.url = "javascript:setVisible('"+columns[i].selectSingleNode("columnId").text+"')";
//alert("1");
menuItems[menuItems.length] = menuItem;
}
}
//alert("1");
menu = {text:"",submenu:{id:"1",itemData:""}}
menu.text = "ColumnPicker";
menu.submenu.id = "ColumnPicker";
menu.submenu.itemData = menuItems;
menus[0] = menu;
var oProductsServicesMenu = new YAHOO.widget.Menu("columnPicker");
oProductsServicesMenu.addItems(menu);
oProductsServicesMenu.render(document.body);
oProductsServicesMenu.show();