From: Pete Hopkins Date: Mon, 30 Jan 2012 17:13:18 +0000 (-0500) Subject: Fires change event when element is selected from menu X-Git-Tag: v2.0.2~62^2~2^2^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=70fecd111566eec3136457afb4143d0950c455b5;p=thirdparty%2Fbootstrap.git Fires change event when element is selected from menu --- diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index c5776df133..df1487bf82 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 455ed415b7..96ea7c45fc 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 +})