Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XBL constructor fires to early?

4 views
Skip to first unread message

Sam Hill

unread,
Jun 30, 2009, 10:48:53 AM6/30/09
to
I am trying to use a binding to adjust the height of the bound element
according to the window height and a ratio provided. This needs to be
done on load. Here is what the method looks like.

<method name="setSpace">
<body>
<![CDATA[
var h = window.innerHeight;
var s = this.getAttribute('space');
this.setAttribute('height',h*s);
]]>
</body>
</method>

and if i call this method from a button it works, but if i call it in
the bindings constructor element ( "this.setSpace()") or in the
window's onload I do not get the correct window. window.innerHeight/
width returns 115X44 which I found to be the window's min. size. It
appears that the constructor and onload try to run before the window
has been fully initialized. I should note that I am trying to run this
on XULRunner and that everything seems to work if i run it in firefox.
Thanks in advanced for any advice guys.

,Sam Hill

Neil

unread,
Jun 30, 2009, 7:19:34 PM6/30/09
to
Sam Hill wrote:

>I am trying to use a binding to adjust the height of the bound element according to the window height and a ratio provided.
>

Unless you are setting a fixed window height (<window height="...">),
the height is calculated from the height of the contained elements, thus
making your calculation self-referential... this also explains why the
height isn't set until after onload, since only then is the document
ready for its size to be calculated.

--
Warning: May contain traces of nuts.

Sam Hill

unread,
Jul 1, 2009, 10:49:12 AM7/1/09
to
The height of the window is being set by an external css but cant be
assumed by the XBL. I was able to solve the problem by using a
setTimeout and a js closure.

var myThis = this;
setTimeout(function(){myThis.setSpace()},1);

Thanks for your response,
Sam Hill

0 new messages