简体   繁体   中英

how to get the dataset name and textfield value in typeahead.js

I am using twitter typeahead.js along with bootstrap 3.0. I have an input type="text" and a search button. I also have two datasets.

When I search and click on the search button, I want to get the dataset name and value in the text field. How do I get the text field value & dataset name? (For example, the values in each dataset can be same, as below, USA is repeating in both datasets).

{
  name: 'Regions',
  local: ["Americas","APAC","EMEA","USA","Mexico","India","China","Malaysia","Belgium"],
  header: '<h3 class="myclass">Regions</h3>'
},
 {
  name: 'Countries',
  local: ["India","USA","Brasil","China"],
  header: '<h3 class="myclass">Clusters</h3>'
}

Add

template: 'Region - {{value}}'

to the first dataset, and

template: 'Country - {{value}}'

to the second dataset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM