我通过cdn添加了typeaheadjs,并具有以下内容,将用户表显示为简单的建议
<script>
$(document).ready(function() {
var bloodhound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/user/find?q=%QUERY%',
wildcard: '%QUERY%'
},
});
$('#search').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'users',
source: bloodhound,
display: function(data) {
return data.name //Input value to be set when you select a suggestion.
},
templates: {
empty: [
'<div class="list-group search-results-dropdown"><div class="list-group-item">Nothing found.</div></div>'
],
header: [
'<div class="list-group search-results-dropdown">'
],
suggestion: function(data) {
return '<div style="font-weight:normal; margin-top:-10px ! important;" class="list-group-item">' + data.name + '</div></div>'
}
}
});
});
</script>
如何从多个表中列出值,以便在用户单击时将它们路由到各自的页面。
我有专业类别,专业人士,业务类别,企业,文章类别,文章表格。我想提前显示所有内容,就像我提到的网站一样