The $(Function)
constructor in gQuery has a different meaning, it is a trick to use the syntax $(this)
inside Functions
.
In the example below $(this)
is a shortcut to $("#input")
or $(element)
. Note that this
points to the inner Function
.
// gwtQuery version
$("#input").click(new Function(){public void f() {
$(this).text('whatever');
}});
As you can see, we do this to have a code very similar to jQuery, so as it is easier to port code from jQuery to gQuery. In the case below this
points to the context where the click is executed: the input element
.
// jQuery version
$("#input").click(function() {
$(this).text('whatever');
});
About onReady question see @Baadshah's answer and my comment.