Question

What's wrong with this code, the basic example if not working. all of the files are in one folder so the path is not the problem, but still this code is not working, how this will work with Web ApI ..?

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.11.1.min.js"></script>
    <script src="typeahead.bundle.min.js"></script>   
    <link href="examples.css" rel="stylesheet" />
    <script type="text/javascript">
        $('input#search-box').typeahead({
  name: 'name',
  local: ['yasser', 'shyam', 'sujesh', 'siddhesh', 'vaibhav']
});
    </script>
</head>
<body>        
    <input type="textbox" placeholder="Search Song" id="search-box" class="typeahead" />
</body>
</html>
Was it helpful?

Solution

Looks like for the very basic example you need to bind a method to the source

http://jsfiddle.net/f9DFC/

$('input#search-box').typeahead(
  {
    minLength: 1,
  },
  {
    name: 'name',
    displayKey: 'value',
    //This needs to me a function, not an array.
    source: substringMatcher( ['yasser', 'shyam', 'sujesh', 'siddhesh', 'vaibhav'])
  });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top