对话框中的 OOB NewForm 在几秒钟后失去焦点

发布于 2024-12-18 04:49:53 字数 786 浏览 3 评论 0原文

在 SharePoint 2010 中使用 SharePoint Designer 2010,我有一个 DispForm,我向其中添加了一个 DVWP,该 DVWP 显示另一个相关列表的筛选视图。 DVWP 有一个“新建”链接,可使用 OpenPopUpPage (http://msdn.microsoft.com/en-us/library/ff410825.aspx)。

5 - 12 秒后,闪烁的光标从第一个控件上消失,焦点切换到“关闭”按钮。如果用户尝试输入内容并在焦点切换到“关闭”按钮时碰巧按下了 Enter 键,则背景不再变暗,并且“取消”按钮不再起作用。该表单仍然显示在屏幕上,用户可以“保存”,但模式永远不会消失,直到刷新页面。

如果用户注意到模式失去了焦点并单击了表单,则一切都会按预期工作并且一切正常。

观察

当控件/模式失去焦点时,“关闭”按钮不会触发“focusin”事件。但是,控制台中显示的 $(document.activeElement).attr("value") 显示它是活动元素。

问题

  1. 为什么模式会失去焦点?
  2. 有谁有 Javascript/jQuery 解决方法来捕获事件并将焦点设置回原来的位置吗?
  3. 或者,如果我锁定表单并等待焦点更改完成,然后解锁并将焦点设置在第一个字段上,该怎么办?有想法吗?

Working in SharePoint 2010, with SharePoint Designer 2010, I have a DispForm to which I've added a DVWP that displays a filtered view of another relative list. The DVWP has a 'New' link which opens the NewForm for that list in a modal dialog, using OpenPopUpPage (http://msdn.microsoft.com/en-us/library/ff410825.aspx).

After 5 - 12 seconds, the blinking cursor disappears from the first control and the focus switches to the 'Close' button. If the user was trying to type and happens to hit the Enter key when the focus switches to the 'Close' button, the background is no longer darkened and the 'Cancel' button no longer works. The form is still displayed on the screen, and the user can 'Save' but the modal never goes away until the page is refreshed.

If the user notices that the modal has lost focus and clicked back on the form, everything works as it should and all is well.

Observations:

When the control/modal loses focus, the 'Close' button does not trigger a 'focusin' event. But, $(document.activeElement).attr("value") displayed in the console shows that it's the active element.

Questions:

  1. Why is the modal losing focus?
  2. Does anyone have a Javascript/jQuery workaround to capture the event and set the focus back where it was?
  3. Alternately, what if I lock the form and wait for this focus-change to complete, then unlock it and set the focus on the first field? Ideas?

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

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

发布评论

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

评论(3

拍不死你 2024-12-25 04:49:53

如果 DispForm 也是一个对话框并且您使用脚本打开模式,您可能会遇到问题。听起来你正在获得“分层”效果。我的猜测是管理对话框的脚本干扰了模式。您是否尝试过关闭列表的对话框?

You may be having a problem if the DispForm is also a dialog and you open the modal with your script. It sounds like you are getting a "layered" effect. My guess is that the script managing the dialog is interfering with the modal. Have you tried turning off the dialiogs for the list?

硬不硬你别怂 2024-12-25 04:49:53

只是为了让我在这个网站上得到一些观点,痛苦是第一个模式的异步刷新。它正在将焦点从分层模式中移开。

谢谢JB的回答!

Just so I get some points on this site, the affliction was the asynchronous refresh of the first modal. It was taking the focus away from the layered modal.

Thanks JB for the answer!

混浊又暗下来 2024-12-25 04:49:53

我发现了问题:DVWP 使用自动刷新和异步更新。它每 15 秒运行一次,将焦点从模态中移开,然后不将其返回到最后一个控件。

因此,我们关闭了自动刷新,并使用模式关闭的回调来触发手动刷新按钮的点击。

I figured out the problem: the DVWP was using Auto-Refresh with the Async Update. This was running every 15 secs, taking the focus away from the modal, then not returning it to the last control.

So, we turned of the auto-refresh and used the callback from the modal close to trigger a click on the manual refresh button instead.

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