3

I am setting up typeahead like so:

       $this.typeahead({ 
            prefetch: $this.data('url-prefetch'), 
            templates: { 
                empty: 'No matching files found' 
            } 
        })

The prefetch is working fine but the empty template is not displayed when there are no matches.

user380689
  • 1,766
  • 4
  • 26
  • 39

2 Answers2

2

To whoever comes across this issue:

"Empty" template will not show up if you have {async:true} in the options

$this.typeahead({
  async: false,
  prefetch: $this.data('url-prefetch'), 
  templates: { 
    empty: 'No matching files found' 
  } 
});
Altin
  • 2,175
  • 3
  • 25
  • 47
1

Fundamental changes have been made in Typeahead.js v0.10.x. Examining your code, it looks like you're targeting Typeahead v0.9.x, so make sure you load this older version, or things won't work.

I suggest you update your code to support v0.10.x, here is a migration guide: https://github.com/twitter/typeahead.js/blob/master/doc/migration/0.10.0.md

bart
  • 14,958
  • 21
  • 75
  • 105