Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#4079 closed bug (invalid)

jQuery 1.3, Append does not appear to be Synchronous

Reported by: Skone Owned by: brandon
Priority: major Milestone: 1.3.2
Component: dimensions Version: 1.3.1
Keywords: outerHeight, append, Cc: [email protected]
Blocked by: Blocking:


My apologies, but I don't have a public test detailing the problem yet, but it can be explained easily with code and is ideally easily reproduceable (I get in trouble for "filing bugs" at work for OSource libraries, so I have to be careful about burning time testing things like this -- I'm envious of those of you who don't get the whip cracked on your back by the inevitable design / advertising agency slave master / monkey /boss).

Anyway, here's the problem:

I append an element to the DOM, and immediately thereafter attempt to get the height of that element. The height will always return 0, however, giving me the inkling that its simply not yet fully inserted into the DOM.

For instance:

var _$div = $('<div>Some Text</div>');
var _$container = $('#container');

The alert will tell me the height is 0. However, if I do the following:

var _$div = $('<div>Some Text</div>');
var _$container = $('#container');
// Wait a second and then see what we've got for a height
setTimeout(functoin() {
}, 1000);

Then I will get the actual height of the element.

Without really investigating the problem this is my supposition -- with the addition of the .live() binding method (which I don't entirely agree with, as I think this type of functionality is a bit DOM heavy but understand that providing it makes the library more competitive with say, regLib), there may have been some sort of change to append() which is creating an additional delay. A simple fix would be to provide a callback for append, in order to ensure that any corresponding functions which depend on the item existing with the DOM can be executed at that point with confidence.

jQuery is the shit! I really appreciate all of the hard work of every contributor, and hope this bug report is a constructive. Please don't hesitate to contact me for clarification (My slave master / boss is going to have to understand one day that he can't prevent me from giving back to Osource libraries like jQuery that make our work possible).

Change History (2)

comment:1 Changed 14 years ago by Skone

This bug should actually be closed as a non-issue, the bug was actually related to other modifications occurring to the DOM during the process of appending which declared that region invisible -- accordingly the element has zero height because its not visible!

My apologies for the erroneous bug report.



comment:2 Changed 14 years ago by dmethvin

Resolution: invalid
Status: newclosed

Thanks for the follow-up. As you found, non-visible elements always return 0 for height and width.

Note: See TracTickets for help on using tickets.