2

I am using Bootstrap Typeahead which I got it from GitHub 1891669. It brings up the suggested words but would like to fix two issues:

The example is here

  • When I click on the item it just prints 0 in text field. What do I do so it prints the full word?
  • How can I make each suggest clickable with the suggest word?

I looked at the code. The Typeahead javascript has the following:

      $.fn.typeahead.defaults = {
     source: []
     , items: 8
     , menu: '<ul class="typeahead dropdown-menu"></ul>'
     , item: '<li><a href="#"></a></li>'
     , onselect: null
     , property: 'value'
     }

so I would like to make href="mylink.php?term=**theword**" so how can I insert suggested word in place of theword in href above so when user clicks on the link it just doesn't fill the text field but rather goes to mylink.php with the parameter.

In that example I have inserted the Typeahead javascript with bootstrap.js. To make it simple for you to view the Typeahead java script here.

thanks

Paolo
  • 20,112
  • 21
  • 72
  • 113
RightAngle
  • 91
  • 8

1 Answers1

0

You're using an older version of Typehead (v2.0.0), which has been updated to fix that issue. Try using the latest version instead: http://twitter.github.io/typeahead.js/examples/

Arman H
  • 5,488
  • 10
  • 51
  • 76
  • I just checked the examples in your provided link and there is no bootstrap. Plus it doesn't have the "source:" field – RightAngle Aug 05 '13 at 21:24
  • This is a stand-alone version of Typehead that's likely going to be integrated with future versions of Bootstrap. It works with Bootstrap just the same: [If you want to use this with a project like Bootstrap, all you have to do is include the JavaScript file for typeahead.js after Bootstrap’s JavaScript file.](https://blog.twitter.com/2013/twitter-typeaheadjs-you-autocomplete-me). Looks like they've renamed `source` to `local`. – Arman H Aug 05 '13 at 21:32
  • I visited the page but it talks all about "prefetch" and no php example. could you look at this:
    – RightAngle Aug 05 '13 at 22:11