mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Fires change event when element is selected from menu
This commit is contained in:
parent
80d03e143c
commit
70fecd1115
2 changed files with 6 additions and 1 deletions
1
js/bootstrap-typeahead.js
vendored
1
js/bootstrap-typeahead.js
vendored
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
6
js/tests/unit/bootstrap-typeahead.js
vendored
6
js/tests/unit/bootstrap-typeahead.js
vendored
|
@ -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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue