2013-05-31 34 views
2

我使用twitter typeahead在搜索欄上工作。除了一個功能,我已經將它用於規範。我需要在鏈接到高級搜索頁面的每個搜索結果的底部添加一個字段。 Im使用knockout.js來填充數據數組。硬編碼值到twitter引導結束typeahead搜索下拉

$('.search').typeahead({ 
      source: function (query, process) { 
       map = {}; 
       $.each(data, function (i, data) { 
        map[data.text] = { 
         address: data.text2 
         , name: data.text 
        }; 
        shops.push(data.text); 
       }); 
       process(shops); 
       shops = []; 
      }, 
      minLength: 3, 
      updater: function (item) { 
       submit_search(item) 
      }, 
      highlighter: function (item) { 
       var p = map[item]; 
       var itm = '' 
         + "<div class='typeahead_wrapper'>" 
         + "<img class='typeahead_photo' src='content/images/pp-icon.png' />" 
         + "<div class='typeahead_labels'>" 
         + "<div class='typeahead_primary'>" + p.name + "</div>" 
         + "<div class='typeahead_secondary'>" + p.address + "</div>" 
         + "</div>" 
         + "</div>"; 
       return itm; 
      }, 


     }); 

我不成功嘗試匹配功能,在每個搜索結束返回額外的項目..任何想法將是真棒。

回答