twitter/typeahead.js

Custom event not triggered

Opened this issue · 3 comments

I'm trying to trigger a custom event like:

typeahead:select but nothing happens. my code is listing the info I want but then when i select nothing happens.
What am I doing wrong?

var route = "autocomplete";
    $('.clientName').typeahead({
        minLength: 1,
        highlight: true,
        source:  function (term, process) {
          return $.get(route, { term: term }, function (data) {
                return process(data);
            });
        }
        
    });

    $('.clientName').on('typeahead:select', function(ev, suggestion) {
      alert("here");
      console.log('Selection: ' + suggestion);
  });
elzix commented

+1

Console logs nothing when I use (from docs)

jQuery('.typeahead').bind('typeahead:select', function(ev, suggestion) {
  console.log('Selection: ' + suggestion);
});
jQuery('.hotel_name').bind('typeahead:select', function(ev, suggestion) {
  console.log('Selection: ' + suggestion);
});

Console logs undefined when I try to add in definition:

jQuery('.hotel_name').typeahead({
  source: function (query, result) {
    jQuery.ajax({ ... });
  },
  select: function (ev, suggestion) {
    console.log('Selection: ' + suggestion);
  }
});

What are we missing?

@elzix looks this is not being supported. :/

The events were changed with version 0.11.0. You are probably using an older version.
In 0.10.5 typeahead:select is typeahead:selected and typeahead:open is typeahead:opened.

This should be in the documentation, but it would probably be better to switch to a supported fork.