Permalink
Browse files

Fires change event when element is selected from menu

  • Loading branch information...
1 parent 80d03e1 commit 70fecd111566eec3136457afb4143d0950c455b5 Pete Hopkins committed Jan 30, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −0 js/bootstrap-typeahead.js
  2. +5 −1 js/tests/unit/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()
}
@@ -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()
})
-})
+})

0 comments on commit 70fecd1

Please sign in to comment.