diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index c5776df133744002b77e421345ecdce43866215e..df1487bf825f44273d1812989a4c1e99d31f0428 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -40,6 +40,7 @@ , select: function () { var val = this.$menu.find('.active').attr('data-value') this.$element.val(val) + this.$element.change(); return this.hide() } diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index 455ed415b7821a726057e4319fb22148e0348405..96ea7c45fce472b41d3d684f2fc94cf3ace47064 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -114,15 +114,19 @@ $(function () { source: ['aa', 'ab', 'ac'] }) , typeahead = $input.data('typeahead') + , changed = false $input.val('a') typeahead.lookup() + $input.change(function() { changed = true }); + $(typeahead.$menu.find('li')[2]).mouseover().click() equals($input.val(), 'ac', 'input value was correctly set') ok(!typeahead.$menu.is(':visible'), 'the menu was hidden') + ok(changed, 'a change event was fired') typeahead.$menu.remove() }) -}) \ No newline at end of file +})