diff --git a/coffee/chosen.jquery.coffee b/coffee/chosen.jquery.coffee index 8cf52709398..2e0c9796a44 100644 --- a/coffee/chosen.jquery.coffee +++ b/coffee/chosen.jquery.coffee @@ -495,9 +495,9 @@ class Chosen extends AbstractChosen w = div.width() + 25 div.remove() - f_width = @container.outerWidth() + f_width = @container[0].offsetWidth - if( w > f_width - 10 ) + if( f_width && w > f_width - 10 ) w = f_width - 10 @search_field.css({'width': w + 'px'}) diff --git a/coffee/chosen.proto.coffee b/coffee/chosen.proto.coffee index 8d895a2d8ba..10424d23d09 100644 --- a/coffee/chosen.proto.coffee +++ b/coffee/chosen.proto.coffee @@ -492,9 +492,9 @@ class @Chosen extends AbstractChosen w = Element.measure(div, 'width') + 25 div.remove() - f_width = @container.getWidth() + f_width = @container.offsetWidth - if( w > f_width-10 ) + if( f_width && w > f_width-10 ) w = f_width - 10 @search_field.setStyle({'width': w + 'px'}) diff --git a/coffee/lib/abstract-chosen.coffee b/coffee/lib/abstract-chosen.coffee index 2a8a7571f4c..b1623fa9b10 100644 --- a/coffee/lib/abstract-chosen.coffee +++ b/coffee/lib/abstract-chosen.coffee @@ -221,7 +221,14 @@ class AbstractChosen else this.results_search() container_width: -> - return if @options.width? then @options.width else "#{@form_field.offsetWidth}px" + return @options.width if @options.width? + + if jQuery? and $ is jQuery + return width if width = $(@form_field).css('width') + else + return width if width = @form_field.getStyle('width') + + @form_field.offsetWidth include_option_in_results: (option) -> return false if @is_multiple and (not @display_selected_options and option.selected)