$(function(){
var orthoObjs = {};
var orthoNames = [];
var throttledRequest = _.debounce(function(query, process){
$.ajax({
url: 'json/ortho4.json'
,cache: false
,success: function(data){
orthoObjs = {};
orthoNames = [];
_.each( data, function(item, ix, list){
orthoNames.push( item.searchPhr );
orthoObjs[ item.searchPhr ] = item;
});
process( orthoNames );
}
});
}, 300);
$(".typeahead").typeahead({
source: function ( query, process ) {
throttledRequest( query, process );
}
,updater: function (item) {
var url = "orthoObjs[item.searchUrl]";
window.location = url;
リダイレクトを機能させる最良の方法は何ですか? 同様の質問を見たことがありますが、これを機能させることはできません。タイプアヘッドに関するドキュメンテーションは良くありません。各関数にunderscore.jsを使用しています。ユーザーが選択したときにリダイレクトする単純な検索クエリが必要なだけです。