Problem with jQuery.fn.position() and Invisible elements
Ran into a little problem with jQuery.fn.position() when the element
that is applied is not visible. If i do:
var pos = $("#divHover").position();
alert(pos.left + " " + pos.top);
On an element that is not visible, jQuery blows up with an error like
this:
[Exception... "Could not convert JavaScript argument arg 0
[nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009
(NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame ::
http://localhost/jqueryWeb/scripts/jQuery.js :: anonymous :: line
878" data: no]
http://localhost/jqueryWeb/scripts/jQuery.js
Line 878
Apparently some of the computed styles are not available causing
jQuery to choke.
The fix is easy enough if you know what the problem is - make the
element visible first, but this is kind of a pain if used in generic
code.
While I'm at it here - why is .position() still not documented in the
1.2.6 docs? Is this function not officially supported by any chance?
+++ Rick ---
Rick Strahl
West Wind Technologies
www.west-wind.com/weblog