我有一个包含 2 个类别的预输入菜单,但在这些类别下我需要一个按钮。如何添加此全局页脚,以便在缺少第二个类别时可用?
我所做的是在每个数据集中添加一个页脚,但使用 CSS 隐藏除最后一个之外的所有数据集,代码如下:
$('#search-query').typeahead([
{
remote: appUrl + 'franchiseesuggestions?query=%QUERY',
name: 'franchisees',
minLength: 3,
valueKey: 'Name',
template: [
'<p><strong>{{Name}}</strong></p>'
].join(''),
header: '<p class="tt-header">' + franchisees + '</p>',
footer: '<p class="more"><a href="/recherche?q=%QUERY">All results</a></p>',
engine: Hogan
}, {
remote: appUrl + 'citysuggestions?query=%QUERY',
name: 'cities',
minLength: 3,
valueKey: 'Name',
template: [
'<p><strong>{{Name}}</strong></p>'
].join(''),
header: '<p class="tt-header">' + cities + '</p>',
footer: '<p class="more"><a href="/recherche?q=%QUERY">All results</a></p>',
engine: Hogan
}
])
还有 CSS 的魔力:
.tt-dropdown-menu .more{
display:none;
}
.tt-dropdown-menu div:last-child .more {
display:block;
}
希望这可以帮助!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)