From 16d131ee8c1163e8597a289294f6f1391bad2902 Mon Sep 17 00:00:00 2001 From: Cal Henderson Date: Thu, 16 Jul 2015 14:18:42 -0700 Subject: [PATCH 1/3] fix the case where no elements have been selected --- ImageSelect.jquery.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ImageSelect.jquery.js b/ImageSelect.jquery.js index f2b5860..1a4dddb 100644 --- a/ImageSelect.jquery.js +++ b/ImageSelect.jquery.js @@ -164,9 +164,11 @@ } }); }); - $this.trigger('chosen:hiding_dropdown'); + this.each(function(input_field) { + $(this).trigger('chosen:hiding_dropdown'); + }); return ret; } }); -})(jQuery); \ No newline at end of file +})(jQuery); From c47d592f8365b85cffec2fd8358485a7afd3b10c Mon Sep 17 00:00:00 2001 From: Cal Henderson Date: Thu, 16 Jul 2015 15:10:40 -0700 Subject: [PATCH 2/3] using the chosen:filter event, allow the filtered results dropdown to have an image attached --- ImageSelect.jquery.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ImageSelect.jquery.js b/ImageSelect.jquery.js index 1a4dddb..0c85b4b 100644 --- a/ImageSelect.jquery.js +++ b/ImageSelect.jquery.js @@ -67,6 +67,9 @@ } } + $this.on('chosen:filter', function(){ + $this.trigger('chosen:showing_dropdown'); + }); }); }); @@ -155,6 +158,12 @@ for(var i = 0; i < lis.length; i++){ var li = lis[i]; var option = options[i]; + + var idx = $(li).attr('data-option-array-index'); + if (idx){ + option = chosen.form_field.options[chosen.results_data[idx].options_index]; + } + var img_src = $(option).attr('data-img-src'); if(img_src != undefined){ From c5fa7d42bc5839aedb30c8572c6a37a243f55d98 Mon Sep 17 00:00:00 2001 From: Cal Henderson Date: Fri, 17 Jul 2015 09:19:34 -0700 Subject: [PATCH 3/3] removed unused function signature --- ImageSelect.jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ImageSelect.jquery.js b/ImageSelect.jquery.js index 0c85b4b..2d8b8ad 100644 --- a/ImageSelect.jquery.js +++ b/ImageSelect.jquery.js @@ -173,7 +173,7 @@ } }); }); - this.each(function(input_field) { + this.each(function() { $(this).trigger('chosen:hiding_dropdown'); }); return ret;