wicket - Ajax 调用不会重置页面焦点

发布于 2024-11-25 04:43:40 字数 684 浏览 0 评论 0原文

我有一个页面,其中包含一个文本框。我已将 AjaxFormComponentUpdatingBehavior 添加到文本框 onchange ,其中我根据其 value 更新了一些其他表单元素。

据我了解, wicket 会在调用后将焦点返回到最后一个焦点组件。但是,在这种情况下,焦点不会返回到组件。所展示的错误行为仅发生在页面加载后的第一个 ajax 调用中,在后续调用中它表现良好。

出现错误时的 wicket-ajax 调试日志看起来像

INFO: Response parsed. Now invoking steps...

INFO: returned focused element: [object HTMLInputElement]

INFO: returned focused element: null

INFO: Response processed successfully.

INFO: Invoking post-call handler(s)...

INFO: refocus last focused component not needed/allowed

Now I'm no wicket Expert ,但我注意到每次 ajax 调用后 wicket 都会记录返回的焦点元素的值两次,在本例中第二次记录为 null 。

如果有人能启发我了解我可能做错了什么,我将不胜感激。感谢您的阅读。

I've a page , which contains a textbox . I've added AjaxFormComponentUpdatingBehavior to the textbox onchange , in which I update a few other form elements based on it's value .

As far as I understand , wicket would return to focus to the last focused component after the call . However , In this case , the focus isn't being returned to the component . The erroneous behavior exhibited happens only for the first ajax call made after the page is loaded , on subsequent calls it behaves fine.

The wicket-ajax debug log in case of the error looks like

INFO: Response parsed. Now invoking steps...

INFO: returned focused element: [object HTMLInputElement]

INFO: returned focused element: null

INFO: Response processed successfully.

INFO: Invoking post-call handler(s)...

INFO: refocus last focused component not needed/allowed

Now I'm no wicket expert , but I have noticed that after every ajax call wicket logs the value of returned focused element twice , the second of which is logging null in this case .

I'd be grateful if anyone could enlighten me on what I could be doing wrong . Thanks for reading .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

全部不再 2024-12-02 04:43:40

这是我对可能出现问题的最佳猜测。

Wicket 通过使用组件的 DOM id 设置变量来跟踪最后一个焦点元素。

如果组件的 DOM id 在事件期间发生更改(Wicket 可以做到这一点,而您却不知道:)),则前端中最后一个焦点元素引用将变得无效。

Here's my best guess as to what might be the problem.

Wicket keeps track of the last focused element is by setting a variable with the DOM id of the component .

If the DOM id of the component gets changed during the event (Wicket can do that , without you knowing :) ) , the last focused element reference in the front-end becomes invalid .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文