bassjobsen / Bootstrap-3-Typeahead

The Typeahead plugin from Twitter's Bootstrap 2 ready to use with Bootstrap 3 and Bootstrap 4
1.68k stars 1.33k forks source link

Issue with getActive and change event #404

Open thekrotek opened 1 year ago

thekrotek commented 1 year ago

I've found a weird issue with "getActive" call when it always returns the 1st match. I added this call according to the documentation, to the "change" event. Problem is that for me change happened earlier than "active" value update here:

this.$element.data('active', val);

I solved this by triggering a custom event:

afterSelect: function(data) { $("input[name='search']").trigger("selected"); },

And then checking it the usual way:

$("input[name='search']").on("selected", function() {