我有一个带有几个悬停点的地图,我正在使用 Bootstrap 弹出窗口来显示有关信息。像这样:http ://benmartinek.com/gisela/asia.html (悬停在新加坡上空)。问题是除非在 JS 中以编程方式完成,否则您无法添加弹出框的链接。
于是我开始在一个对象中写入所有信息:
locationHash = {
"singapore": ["Singapore", "some text 1", '<a href="http://travel.nytimes.com/2012/01/22/travel/hawker-food-courts-in-singapore.html?pagewanted=all"Link</a>'],
"skorea": ["Seoul", "some text 2", '<a href="http://travel.nytimes.com/2012/01/22/travel/hawker-food-courts-in-singapore.html?pagewanted=all"Link</a> '],
}
当我尝试访问它时,这里没有问题接受。当悬停在韩国上空时,我仍然得到“新加坡”作为标题。这是代码:
$('.locations').each(function(i) {
locationId = $('.locations')[i].id;
locationTitle = ('' + locationHash[locationId][0]);
$("[rel=popover]").popover({
animation: true,
html: true,
trigger: 'hover',
offset: 10,
title: locationTitle,
placement: 'right',
delay: {
show: 200,
hide: 1500
}
});
});
这是因为尚未生成弹出框吗?对此有更好策略的建议?