From 3246598cbb93b66026828ab85754c65378f43ea9 Mon Sep 17 00:00:00 2001 From: Roberto Date: Wed, 14 Aug 2013 19:20:21 -0700 Subject: [PATCH 1/2] Timing of 'chosen:showing_dropdown' fixed Currently the event is triggered before dropdown LI's are created. This commit corrects it by moving the trigger event at end of method. A JSFIDDLE was created to demonstrate the issue. http://jsfiddle.net/lagrz/3A5jq/ By moving the event it enables developers to add whatever additional code or styling to the dropdown menu options such as images. --- coffee/chosen.jquery.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 827f785872c..6da87a529e7 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -224,7 +224,6 @@ class Chosen extends AbstractChosen return false @container.addClass "chosen-with-drop" - @form_field_jq.trigger("chosen:showing_dropdown", {chosen: this}) @results_showing = true @@ -232,6 +231,7 @@ class Chosen extends AbstractChosen @search_field.val @search_field.val() this.winnow_results() + @form_field_jq.trigger("chosen:showing_dropdown", {chosen: this}) update_results_content: (content) -> @search_results.html content From 3de4433c7b91c5a255a638bf6630df523b19c64d Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Thu, 15 Aug 2013 17:44:55 -0500 Subject: [PATCH 2/2] Fire the `chosen:showing_dropdown` event only after results are totally built. Further information about this fix is described in: 3246598cbb93b66026828ab85754c65378f43ea9 --- coffee/chosen.jquery.coffee | 1 - coffee/chosen.proto.coffee | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 6da87a529e7..f3d045486f2 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -224,7 +224,6 @@ class Chosen extends AbstractChosen return false @container.addClass "chosen-with-drop" - @results_showing = true @search_field.focus() diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index f2e511cd000..2ac0276f96c 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -218,14 +218,13 @@ class @Chosen extends AbstractChosen return false @container.addClassName "chosen-with-drop" - @form_field.fire("chosen:showing_dropdown", {chosen: this}) - @results_showing = true @search_field.focus() @search_field.value = @search_field.value this.winnow_results() + @form_field.fire("chosen:showing_dropdown", {chosen: this}) update_results_content: (content) -> @search_results.update content