Skip to content

Source element outerWidth unreliable if styled to 100% #546

@p0lar-bear

Description

@p0lar-bear

The refresh() method calls a private function that gets the width of the select element the multiselect is based on via $().outerWidth(), then sets the generated button element to that or the specified minWidth option. However, I found that this is unreliable, and gets wonky if the select element is styled via CSS to have a 100% width.

I noticed this first when using it within Bootstrap while using a jQUI theme to make it get along with bootstrap: http://jsfiddle.net/p0lar_bear/xFcKd/

So I tested what I thought was the problem using custom styling instead of Bootstrap, and got a similar result: http://jsfiddle.net/p0lar_bear/nctp6/

It seems that in at least Firefox or Chrome, a <select> with its display set to "none" has its width calculated entirely differently than when it's visible. In the second example, if I run $('#sel').outerWidth() while it's visible (display: block), I get an expected result of 300. Hiding it, and then getting the outerWidth again gets me a much larger number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions