I've developed a jQuery Widget, one of the things it does is appends
html and checks its width. This works standalone, but as soon as I
use it inside GWT page, the jQuery.width()/innerWidth()/outerWidth()
gets unexpected results, most often 0. Seems like there's a race
condition between the assignment of actual widths and me calling this
being available to width(). Is there a way to ensure that dynamically
created html is ready for subsequent use?
eg.
// css: .header { padding: 10px; }
$(root).append('<div id="h1">AAA</div>');
var h = $('#h1', root)
h.text(); // ok, gets AAA
h.width(); // most often 0
h.outerWidth(); // sometimes 0, sometimes 20 (10+10 of padding)
I also notice similar case in event handling - outside of GWT page
it's ok to bind jQuery hadlers and then trigger them straight after.
Inside GWT, the initial trigger might just be eaten up, eg:
$('.scrollable', root).bind('scroll', function(ui) {
console.log('scrolled!');
});
$('.scrolable', root).scrollLeft(100); // might not print "scrolled!"
This behaviour appears in both GWT Development mode and Compiled mode.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.