From 1dd51001228074372ca523ac6d364e65f95cee9c Mon Sep 17 00:00:00 2001 From: Patrick Filler Date: Wed, 20 Jul 2011 11:29:23 -0400 Subject: [PATCH] Prevent duplicate jQuery Chosen calls. --- chosen/chosen.jquery.js | 5 ++++- coffee/chosen.jquery.coffee | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chosen/chosen.jquery.js b/chosen/chosen.jquery.js index 7a4f7ac..55dace1 100644 --- a/chosen/chosen.jquery.js +++ b/chosen/chosen.jquery.js @@ -13,7 +13,9 @@ $.fn.extend({ chosen: function(data, options) { return $(this).each(function(input_field) { - return new Chosen(this, data, options); + if (!($(this)).hasClass("chzn-done")) { + return new Chosen(this, data, options); + } }); } }); @@ -26,6 +28,7 @@ this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option"; this.set_up_html(); this.register_observers(); + this.form_field_jq.addClass("chzn-done"); } Chosen.prototype.set_default_values = function() { this.click_test_action = __bind(function(evt) { diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 339f1e0..a9f6a1a 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -13,7 +13,7 @@ $ = jQuery $.fn.extend({ chosen: (data, options) -> $(this).each((input_field) -> - new Chosen(this, data, options) + new Chosen(this, data, options) unless ($ this).hasClass "chzn-done" ) }) @@ -30,6 +30,7 @@ class Chosen this.set_up_html() this.register_observers() + @form_field_jq.addClass "chzn-done" set_default_values: ->