Skip to content

Commit f6e99d2

Browse files
committed
Autocomplete: Combobox demo - Collapse menu when clicking button.
1 parent 1f5dd8d commit f6e99d2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

demos/autocomplete/combobox.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_create: function() {
4040
var input,
4141
that = this,
42+
wasOpen = false,
4243
select = this.element.hide(),
4344
selected = select.children( ":selected" ),
4445
value = selected.val() ? selected.text() : "",
@@ -129,20 +130,19 @@
129130
})
130131
.removeClass( "ui-corner-all" )
131132
.addClass( "ui-corner-right ui-combobox-toggle" )
133+
.mousedown(function() {
134+
wasOpen = input.autocomplete( "widget" ).is( ":visible" );
135+
})
132136
.click(function() {
137+
input.focus();
138+
133139
// close if already visible
134-
if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
135-
input.autocomplete( "close" );
136-
removeIfInvalid( input );
140+
if ( wasOpen ) {
137141
return;
138142
}
139143

140-
// work around a bug (likely same cause as #5265)
141-
$( this ).blur();
142-
143144
// pass empty string as value to search for, displaying all results
144145
input.autocomplete( "search", "" );
145-
input.focus();
146146
});
147147

148148
input.tooltip({

0 commit comments

Comments
 (0)