Vaadin 组件的 JS 回调
我有一个 JS 组件(SigPlot),我需要从中读取点击值。我已经在 VerticalLayout 内部实例化了 SigPlot,同时还实例化了一个 DIV 以传递给 SigPlot 构造函数。我不确定这是否是有效的方法,但它确实有效。 现在我需要阅读 CLICKS,但我很难找到正确的方法来做到这一点。有人可以传授一些至理名言吗?
在我的 VIEW 的构造函数中,它使用 addAttachListener 来启动我的 JS 代码。
div.addAttachListener(e->{
e.getUI().getPage().executeJs("myInit($0)",div);
});
我怎样才能注册一个点击监听器呢?
问候
I have a JS component (SigPlot) that I need to read click values from. I have instantiated SigPlot inside of a VerticalLayout, where I also instantiate a DIV to pass to the SigPlot constructor. I am not sure if this is a valid way, but it works.
Now I need to read CLICKS but I am having troubles finding correct way to do this. Can someone pass some words of wisdom?
In my constructor for my VIEW, it use addAttachListener to start my JS code using.
div.addAttachListener(e->{
e.getUI().getPage().executeJs("myInit($0)",div);
});
How can I register a click listener to this?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要它只是一个常规的 DOM 事件监听器,那么这样的事情应该可以工作:
如果您需要在更细粒度的级别上执行某些操作,那么您可能希望将回调公开为
@ClientCallable
,然后使用executeJs
运行一些简短的 JavaScript 片段来设置委托给这些方法的侦听器。As long as it's just a regular DOM event listener, then something like this should work:
If you need to do something on a more granular level, then your might want to expose callbacks as
@ClientCallable
and then useexecuteJs
to run some short JavaScript snippets to set up listeners that delegate to those methods.