Opened 11 years ago
Closed 11 years ago
#11086 closed bug (invalid)
.outerWidth() returns an incorrect value when used on a jQuery UI button element with a label that contains a space.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | dimensions | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This issue involves both jQuery Core and jQuery UI, yet I'm not sure which is causing the problem.
I'm using the latest version of Chrome.
I'm trying to build a button container that is sized perfectly to match the contained buttons. To do this, I'm using .outerWidth(), which works perfectly most of the time. However, as soon as I add a button with a label containing a space, .outerWidth() reports an incorrect value. Replacing a space with the html entity ( ) also works properly.
Example 1
var $button = $("<button />");
$button.html("Foo").button().outerWidth(); Works, returns 128.
Example 2
var $button = $("<button />");
$button.html("Foo Bar").button().outerWidth(); Fails, returns 81, is actually 128.
Example 3
var $button = $("<button />");
$button.html("Foo Bar").button().outerWidth(); Works, Returns 128.
Change History (2)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Component: | unfiled → dimensions |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
There's probably some other factors in your code causing a problem. Closing this for now. Feel free to reopen this if you can reproduce it in a simplified jsfiddle testcase.
I just realized that, in my above examples, I failed to show $button being appended to the document (and they were not in jsFiddle). However, the issue is not presenting itself in jsFiddle, so perhaps there is an additional factor that I have overlooked.
http://jsfiddle.net/F7p8L/2/