typeahead.js icon indicating copy to clipboard operation
typeahead.js copied to clipboard

Custom event not triggered

Open luisalmeida12 opened this issue 6 years ago • 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);
  });

luisalmeida12 avatar Dec 25 '19 02:12 luisalmeida12

+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 avatar Jan 23 '20 10:01 elzix

@elzix looks this is not being supported. :/

luisalmeida12 avatar Mar 22 '20 15:03 luisalmeida12

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.

Canyoneer avatar May 07 '20 13:05 Canyoneer