diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-12-13 16:55:14 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-12-13 16:55:14 -0500 |
commit | f6e99d2021bf9865673d08a4cef4d67ba7c586a5 (patch) | |
tree | 5944aa212ada7482de1fc70f9ee14db02ec5d9c3 /demos/autocomplete/combobox.html | |
parent | 1f5dd8d68ef568ea4ec28c3881ba438e4f946f3f (diff) | |
download | jquery-ui-f6e99d2021bf9865673d08a4cef4d67ba7c586a5.tar.gz jquery-ui-f6e99d2021bf9865673d08a4cef4d67ba7c586a5.zip |
Autocomplete: Combobox demo - Collapse menu when clicking button.
Diffstat (limited to 'demos/autocomplete/combobox.html')
-rw-r--r-- | demos/autocomplete/combobox.html | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 6229d47b2..38c75e157 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -39,6 +39,7 @@ _create: function() { var input, that = this, + wasOpen = false, select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : "", @@ -129,20 +130,19 @@ }) .removeClass( "ui-corner-all" ) .addClass( "ui-corner-right ui-combobox-toggle" ) + .mousedown(function() { + wasOpen = input.autocomplete( "widget" ).is( ":visible" ); + }) .click(function() { + input.focus(); + // close if already visible - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); - removeIfInvalid( input ); + if ( wasOpen ) { return; } - // work around a bug (likely same cause as #5265) - $( this ).blur(); - // pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); - input.focus(); }); input.tooltip({ |