Fix issue with dotted ids.

Closes Gh-54
This commit is contained in:
pfiller 2011-07-26 15:10:16 -04:00
parent 2f95023612
commit d399196f52
4 changed files with 6 additions and 6 deletions

View file

@ -43,7 +43,7 @@
}; };
Chosen.prototype.set_up_html = function() { Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width; var container_div, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id.length ? this.form_field.id : this.generate_field_id(); this.container_id = this.form_field.id.length ? this.form_field.id.replace('.', '_') : this.generate_field_id();
this.container_id += "_chzn"; this.container_id += "_chzn";
this.f_width = this.form_field_jq.width(); this.f_width = this.form_field_jq.width();
this.default_text = this.form_field_jq.attr('title') ? this.form_field_jq.attr('title') : this.default_text_default; this.default_text = this.form_field_jq.attr('title') ? this.form_field_jq.attr('title') : this.default_text_default;
@ -686,7 +686,7 @@
}; };
Chosen.prototype.generate_random_id = function() { Chosen.prototype.generate_random_id = function() {
var string; var string;
string = 'sel' + this.generate_random_char() + this.generate_random_char() + this.generate_random_char(); string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
while ($("#" + string).length > 0) { while ($("#" + string).length > 0) {
string += this.generate_random_char(); string += this.generate_random_char();
} }

View file

@ -35,7 +35,7 @@
}; };
Chosen.prototype.set_up_html = function() { Chosen.prototype.set_up_html = function() {
var base_template, container_props, dd_top, dd_width, sf_width; var base_template, container_props, dd_top, dd_width, sf_width;
this.container_id = this.form_field.identify() + "_chzn"; this.container_id = this.form_field.identify().replace('.', '_') + "_chzn";
this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth(); this.f_width = this.form_field.getStyle("width") ? parseInt(this.form_field.getStyle("width"), 10) : this.form_field.getWidth();
container_props = { container_props = {
'id': this.container_id, 'id': this.container_id,

View file

@ -43,7 +43,7 @@ class Chosen
@choices = 0 @choices = 0
set_up_html: -> set_up_html: ->
@container_id = if @form_field.id.length then @form_field.id else this.generate_field_id() @container_id = if @form_field.id.length then @form_field.id.replace('.', '_') else this.generate_field_id()
@container_id += "_chzn" @container_id += "_chzn"
@f_width = @form_field_jq.width() @f_width = @form_field_jq.width()
@ -585,7 +585,7 @@ class Chosen
new_id new_id
generate_random_id: -> generate_random_id: ->
string = 'sel' + this.generate_random_char() + this.generate_random_char() + this.generate_random_char() string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char()
while $("#" + string).length > 0 while $("#" + string).length > 0
string += this.generate_random_char() string += this.generate_random_char()
string string

View file

@ -41,7 +41,7 @@ class Chosen
set_up_html: -> set_up_html: ->
@container_id = @form_field.identify() + "_chzn" @container_id = @form_field.identify().replace('.', '_') + "_chzn"
@f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth() @f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()