我最近一直在与the Twitter typeahead jQuery plugin一起工作。它主要是工作,但它给了我'未定义'作为搜索结果。
这是我的folder.js.coffee:
$(document).ready ->
console.log("searchhhhh");
haunt = undefined
repos = undefined
repos = new Bloodhound(
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value')
queryTokenizer: Bloodhound.tokenizers.whitespace
limit: 10
prefetch:
url: '/auto_search.json',
filter: (list) ->
$.map list.results, (auto) ->
{ value: auto }
)
repos.initialize()
$('#auto_search').typeahead null,
name: 'repos'
displayKey: 'value'
source: repos.ttAdapter()
return
答案 0 :(得分:0)
这很有用。
$(document).ready ->
console.log("searchhhhh");
haunt = undefined
repos = undefined
repos = new Bloodhound(
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name')
queryTokenizer: Bloodhound.tokenizers.whitespace
limit: 10
prefetch:
url: '/auto_search.json',
filter: (list) ->
$.map list.results, (auto) ->
{ value: auto }
)
repos.initialize()
$('#auto_search').typeahead null,
name: 'repos'
displayKey: 'name'
source: repos.ttAdapter()
return