Prevent duplicate jQuery Chosen calls.

This commit is contained in:
Patrick Filler 2011-07-20 11:29:23 -04:00
parent cb7bf985a0
commit 1dd5100122
2 changed files with 6 additions and 2 deletions

View file

@ -13,7 +13,9 @@
$.fn.extend({ $.fn.extend({
chosen: function(data, options) { chosen: function(data, options) {
return $(this).each(function(input_field) { return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) {
return new Chosen(this, data, options); 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.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
this.set_up_html(); this.set_up_html();
this.register_observers(); this.register_observers();
this.form_field_jq.addClass("chzn-done");
} }
Chosen.prototype.set_default_values = function() { Chosen.prototype.set_default_values = function() {
this.click_test_action = __bind(function(evt) { this.click_test_action = __bind(function(evt) {

View file

@ -13,7 +13,7 @@ $ = jQuery
$.fn.extend({ $.fn.extend({
chosen: (data, options) -> chosen: (data, options) ->
$(this).each((input_field) -> $(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.set_up_html()
this.register_observers() this.register_observers()
@form_field_jq.addClass "chzn-done"
set_default_values: -> set_default_values: ->