然而,matcher函数会导致我的高亮笔中断并随机返回结果。我想我可能采取了错误的方法。
$('.shop_search').typeahead({
source: function (query, process) {
map = {};
$.each(data, function (i, data) {
map[data.text] = {
address: data.text2,
name: data.text,
post: data.post
};
shops.push(data.text);
});
process(shops);
shops = [];
},
minLength: 3,
matcher: function (item) {
if (item.indexOf(this.query) == -1) {
$(".dropdown-menu").append($('<li><button class="btn" >Advanced Search</button></li>'));
return true;
}
},
highlighter: function (item) {
var p = map[item];
var itm = ''
+ "<div class='typeahead_primary'>" + p.name + "</div>"
+ "<div class='typeahead_secondary'>" + p.address + </div>"
+ "</div>"
+ "</div>";
return itm;
},
});发布于 2013-06-18 20:40:19
在我看来,你忘了一个“
+ "<div class='typeahead_secondary'>" + p.address + </div>"应该是
+ "<div class='typeahead_secondary'>" + p.address + "</div>"https://stackoverflow.com/questions/17167089
复制相似问题