diff --git a/index.html b/index.html index 13f5272..a9aa500 100644 --- a/index.html +++ b/index.html @@ -21,8 +21,8 @@ - + - \ No newline at end of file + diff --git a/js/jquery.sparkbox-select.js b/js/jquery.sparkbox-select.js index abc6d15..8fd7e6c 100644 --- a/js/jquery.sparkbox-select.js +++ b/js/jquery.sparkbox-select.js @@ -54,8 +54,13 @@ // Clear keystroke matching string and show dropdown var viewList = function(e) { var $this = $(this), - id = $this.data('id'); - + id = $this.data('id'), + $current = $('.sb-dropdown[data-id=' + $this.data('id') + ']').find('.selected'); + if ($current.is(':visible')){ + hideDropdown($current[0]); + return; + } + clearKeyStrokes(); $('.sb-dropdown').filter('[data-id!=' + id + ']').fadeOut('fast'); @@ -186,10 +191,10 @@ // Hide dropdown when click is outside of the input or dropdown $(document).bind('click', hideDropdown); - $('.sb-custom').find('.sb-select').live('keydown', selectKeypress); + $('.sb-custom').find('.sb-select').on('keydown', selectKeypress); $('.sb-custom').bind('blur', clearKeyStrokes); $(document).delegate('.sb-dropdown', 'focus', viewList); return this; }; -})(jQuery); \ No newline at end of file +})(jQuery);