Reputation: 111
I have to check if the bottom of scroll has been hit by the user.
The JavaScript code is:
$(window).scroll(function() {
if ($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
`enter code here` // How to write this code in JSNI in GWT? I tried but got no result.
I have written the above code in JSNI as follows:
/*-{
$wnd.$(window).scroll(function() {
console.log("WS"+$wnd.$(window).scrollTop());
$wnd.alert("hi");
});
}-*/;
Upvotes: 0
Views: 197
Reputation: 3682
you can also make use of GWT jquery wrapper: https://github.com/gwtquery/gwtquery
Upvotes: 0
Reputation: 64541
You need to replace all your uses of window
with $wnd
too.
But I agree with Knarf and El Hoss that you should avoid using JSNI nowadays to be future-proof. Either use what GWT already provides, or Elemental 2, or possibly use jQuery through JsInterop rather than JSNI.
Upvotes: 1
Reputation: 2156
I think this can be achieved in normal GWT without any need for native code or jquery.
Some methods that may help
Upvotes: 1