From a8939c92bd45c5d9f8983be7daca8bd70db76476 Mon Sep 17 00:00:00 2001 From: Scott Joudry Date: Tue, 13 May 2014 15:10:40 -0300 Subject: [PATCH] fixed blur so click gets fired --- fancySelect.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) mode change 100644 => 100755 fancySelect.js diff --git a/fancySelect.js b/fancySelect.js old mode 100644 new mode 100755 index b6c8215..35deb5c --- a/fancySelect.js +++ b/fancySelect.js @@ -5,7 +5,7 @@ $ = window.jQuery || window.Zepto || window.$; $.fn.fancySelect = function(opts) { - var isiOS, settings; + var isiOS, settings, clicking = true; if (opts == null) { opts = {}; } @@ -57,10 +57,9 @@ return trigger.html(triggerHtml); }; sel.on('blur.fs', function() { + if (clicking) return; if (trigger.hasClass('open')) { - return setTimeout(function() { - return trigger.trigger('close.fs'); - }, 120); + return trigger.trigger('close.fs'); } }); trigger.on('close.fs', function() { @@ -162,8 +161,12 @@ } options.find('.selected').removeClass('selected'); clicked.addClass('selected'); + clicking = false; return sel.val(clicked.data('raw-value')).trigger('change.fs').trigger('blur.fs').trigger('focus.fs'); }); + options.on('mousedown.fs', 'li', function() { + clicking = true; + }); options.on('mouseenter.fs', 'li', function() { var hovered, nowHovered; nowHovered = $(this);