Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#984 closed bug (invalid)

$(element).width() & $(element).height() functions return incorrect values

Reported by: elemerz Owned by:
Priority: minor Milestone: 1.1.2
Component: core Version: 1.1.1
Keywords: Layout Manager Cc:
Blocked by: Blocking:


$(element).width() & $(element).height() functions return incorrect values. I rewrote the prototype 1.5.0 -based [RUZEE layout Manager|http://www.ruzee.com/blog/ruzeelayoutmanager/] for jQuery. I needed to get the dimensions of an element, in form of a hash like: {width:widthValue,height:heightValue}. I used: {width:$(element).width(), height:$(element).height()} in the jQuery version. I noticed that these two functions (width(), and height()) do not return the same values like Element.getDimensions(element) used by prototype. My jQuery -based rewritten version of the above mentioned LayoutManager does not render correctly because of these differences. To see in action what I'm talking about, set the useJQueryDimensions variable inside of lm.jquery.js file in the attachment. Thanx in advance,

Elemér. In the attachment you can find

Attachments (1)

BugReport.zip (18.0 KB) - added by elemerz 16 years ago.
Layout Manager based on jQuery.

Download all attachments as: .zip

Change History (5)

Changed 16 years ago by elemerz

Attachment: BugReport.zip added

Layout Manager based on jQuery.

comment:1 Changed 16 years ago by alexo

This ticket is related to core component, not ajax...

comment:2 Changed 16 years ago by john

Component: ajaxcore
Priority: majorminor

I'm not entirely sure what I'm supposed to be seeing - but I did notice that you subtract the padding and border widths from the height/width - jQuery already does this. The .height() and .width() returned by jQuery do not include those numbers, and are stable across browsers.

Additionally, you may want to look into the Dimensions plugin, which will reduce the size of your plugin by about 90%, it looks like.


comment:3 Changed 16 years ago by brandon

Resolution: invalid
Status: newclosed

As John mentioned, the jQuery width and height methods return the actual computed CSS width and height. If you want the offset width (includes padding and border) you should use the dimensions plugin outerWidth method (it also accounts for if an element is display: none).

Also just a note ... you can pass the css method numbers and it will append the "px" for you.

comment:4 Changed 12 years ago by anonymous


== ==


Note: See TracTickets for help on using tickets.