From 91502810c99bf79ab58e49ce6a8b0ccc6ec3b212 Mon Sep 17 00:00:00 2001 From: Jerrett Date: Wed, 9 Nov 2011 16:49:13 -0800 Subject: [PATCH 1/3] not explode on empty selects with allow_single_deselect --- chosen/chosen.jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chosen/chosen.jquery.js b/chosen/chosen.jquery.js index a81cf46..0184083 100644 --- a/chosen/chosen.jquery.js +++ b/chosen/chosen.jquery.js @@ -113,7 +113,7 @@ this.results_showing = false; this.result_highlighted = null; this.result_single_selected = null; - this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; + this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0] && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; this.disable_search_threshold = this.options.disable_search_threshold || 0; this.choices = 0; return this.results_none_found = this.options.no_results_text || "No results match"; From acf540ff21266657f4054d4fc227c7e136dbf47f Mon Sep 17 00:00:00 2001 From: Jerrett Date: Mon, 14 Nov 2011 16:18:18 -0800 Subject: [PATCH 2/3] changes to .coffee file instead --- coffee/lib/abstract-chosen.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index e1dcf4c..3d9222f 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -27,7 +27,7 @@ class AbstractChosen @results_showing = false @result_highlighted = null @result_single_selected = null - @allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0].text == "" then @options.allow_single_deselect else false + @allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0] and @form_field.options[0].text == "" then @options.allow_single_deselect else false @disable_search_threshold = @options.disable_search_threshold || 0 @choices = 0 @results_none_found = @options.no_results_text or "No results match" From 5d0e5855c798aefad360b190d02329a43c7f5329 Mon Sep 17 00:00:00 2001 From: Jerrett Date: Mon, 14 Nov 2011 16:19:41 -0800 Subject: [PATCH 3/3] Revert "not explode on empty selects with allow_single_deselect" This reverts commit 91502810c99bf79ab58e49ce6a8b0ccc6ec3b212. --- chosen/chosen.jquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chosen/chosen.jquery.js b/chosen/chosen.jquery.js index 0184083..a81cf46 100644 --- a/chosen/chosen.jquery.js +++ b/chosen/chosen.jquery.js @@ -113,7 +113,7 @@ this.results_showing = false; this.result_highlighted = null; this.result_single_selected = null; - this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0] && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; + this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; this.disable_search_threshold = this.options.disable_search_threshold || 0; this.choices = 0; return this.results_none_found = this.options.no_results_text || "No results match";