From 37bd3070f68058055c9582205b1762b7ef30c1a0 Mon Sep 17 00:00:00 2001 From: Kristof Degrave Date: Fri, 1 Dec 2017 21:13:11 +0100 Subject: [PATCH] Fixed some issues when clicking on an item when using the bootstrap 4 template --- bootstrap3-typeahead.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bootstrap3-typeahead.js b/bootstrap3-typeahead.js index e0ac9a6..3c13697 100644 --- a/bootstrap3-typeahead.js +++ b/bootstrap3-typeahead.js @@ -379,7 +379,7 @@ var next = active.next(); if (!next.length) { - next = $(this.$menu.find('li')[0]); + next = $(this.$menu.find($(this.options.item).prop('tagName'))[0]); } next.addClass('active'); @@ -393,7 +393,7 @@ var prev = active.prev(); if (!prev.length) { - prev = this.$menu.find('li').last(); + prev = this.$menu.find($(this.options.item).prop('tagName')).last(); } prev.addClass('active'); @@ -414,15 +414,16 @@ this.$element.on('keydown', $.proxy(this.keydown, this)); } + var itemTagName = $(this.options.item).prop('tagName') if ('ontouchstart' in document.documentElement) { this.$menu - .on('touchstart', 'li', $.proxy(this.touchstart, this)) - .on('touchend', 'li', $.proxy(this.click, this)); + .on('touchstart', itemTagName, $.proxy(this.touchstart, this)) + .on('touchend', itemTagName, $.proxy(this.click, this)); } else { this.$menu .on('click', $.proxy(this.click, this)) - .on('mouseenter', 'li', $.proxy(this.mouseenter, this)) - .on('mouseleave', 'li', $.proxy(this.mouseleave, this)) + .on('mouseenter', itemTagName, $.proxy(this.mouseenter, this)) + .on('mouseleave', itemTagName, $.proxy(this.mouseleave, this)) .on('mousedown', $.proxy(this.mousedown,this)); } },