mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Autocomplete: Combobox demo - Collapse menu when clicking button.
This commit is contained in:
parent
1f5dd8d68e
commit
f6e99d2021
@ -39,6 +39,7 @@
|
|||||||
_create: function() {
|
_create: function() {
|
||||||
var input,
|
var input,
|
||||||
that = this,
|
that = this,
|
||||||
|
wasOpen = false,
|
||||||
select = this.element.hide(),
|
select = this.element.hide(),
|
||||||
selected = select.children( ":selected" ),
|
selected = select.children( ":selected" ),
|
||||||
value = selected.val() ? selected.text() : "",
|
value = selected.val() ? selected.text() : "",
|
||||||
@ -129,20 +130,19 @@
|
|||||||
})
|
})
|
||||||
.removeClass( "ui-corner-all" )
|
.removeClass( "ui-corner-all" )
|
||||||
.addClass( "ui-corner-right ui-combobox-toggle" )
|
.addClass( "ui-corner-right ui-combobox-toggle" )
|
||||||
|
.mousedown(function() {
|
||||||
|
wasOpen = input.autocomplete( "widget" ).is( ":visible" );
|
||||||
|
})
|
||||||
.click(function() {
|
.click(function() {
|
||||||
|
input.focus();
|
||||||
|
|
||||||
// close if already visible
|
// close if already visible
|
||||||
if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
|
if ( wasOpen ) {
|
||||||
input.autocomplete( "close" );
|
|
||||||
removeIfInvalid( input );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// work around a bug (likely same cause as #5265)
|
|
||||||
$( this ).blur();
|
|
||||||
|
|
||||||
// pass empty string as value to search for, displaying all results
|
// pass empty string as value to search for, displaying all results
|
||||||
input.autocomplete( "search", "" );
|
input.autocomplete( "search", "" );
|
||||||
input.focus();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
input.tooltip({
|
input.tooltip({
|
||||||
|
Loading…
Reference in New Issue
Block a user