Darnok
unread,Sep 14, 2011, 12:42:53 PM9/14/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
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.