Commit 70fecd11 authored by Pete Hopkins's avatar Pete Hopkins

Fires change event when element is selected from menu

parent 80d03e14
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
, select: function () { , select: function () {
var val = this.$menu.find('.active').attr('data-value') var val = this.$menu.find('.active').attr('data-value')
this.$element.val(val) this.$element.val(val)
this.$element.change();
return this.hide() return this.hide()
} }
......
...@@ -114,14 +114,18 @@ $(function () { ...@@ -114,14 +114,18 @@ $(function () {
source: ['aa', 'ab', 'ac'] source: ['aa', 'ab', 'ac']
}) })
, typeahead = $input.data('typeahead') , typeahead = $input.data('typeahead')
, changed = false
$input.val('a') $input.val('a')
typeahead.lookup() typeahead.lookup()
$input.change(function() { changed = true });
$(typeahead.$menu.find('li')[2]).mouseover().click() $(typeahead.$menu.find('li')[2]).mouseover().click()
equals($input.val(), 'ac', 'input value was correctly set') equals($input.val(), 'ac', 'input value was correctly set')
ok(!typeahead.$menu.is(':visible'), 'the menu was hidden') ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
ok(changed, 'a change event was fired')
typeahead.$menu.remove() typeahead.$menu.remove()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment