我必须检查滚动的底部是否已被用户点击。
JavaScript代码为:
$(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.我已经用JSNI编写了上述代码,如下所示:
/*-{
$wnd.$(window).scroll(function() {
console.log("WS"+$wnd.$(window).scrollTop());
$wnd.alert("hi");
});
}-*/;发布于 2017-10-19 20:20:31
我认为这可以在普通的GWT中实现,而不需要任何本机代码或jquery。
发布于 2017-10-19 23:07:38
您也需要用$wnd替换所有window的用法。
但我同意Knarf和El Hoss的观点,你现在应该避免使用JSNI,以适应未来。要么使用GWT已经提供的东西,要么使用Elemental2,或者可能通过JsInterop而不是JSNI使用jQuery。
发布于 2017-10-21 23:22:49
您还可以使用GWT jquery包装器:https://github.com/gwtquery/gwtquery
https://stackoverflow.com/questions/46826917
复制相似问题