Jquery datepicker 中的事件冒泡

发布于 2025-01-07 15:02:14 字数 211 浏览 4 评论 0原文

我有一个弹出菜单,其中包含带有 jquery 日期选择器的表单,问题是当我选择日期时,菜单和日期选择器日历都会关闭。

我尝试在日期选择器的 Select 事件中使用 event.stopPropagation() ,但是我找不到获取“事件”句柄的方法。

另外,我尝试在选择事件结束时返回 false,但再次没有运气。任何帮助将不胜感激。谢谢。

I have a pop menu that contains a form with a jquery datepicker and the issue is that when I make a date selection, both the menu and the datepicker calendar closes.

I tried to use event.stopPropagation() in the Select event for the datepicker, but the I couldn't find a way to get a handle for the "event".

Also, I tried to return false at the end of the select event but again with no luck. Any help will be much appreciated. Thanks.

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

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

发布评论

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

评论(3

七禾 2025-01-14 15:02:14

我遇到了同样的问题,并通过添加准备好的文档来修复它:

/*Stop datepicker from closing dropdown menu*/
    $("#ui-datepicker-div").click( function(event) {
        event.stopPropagation();
    });

技巧是 datepicker 创建一个带有 id ui-datepicker-div 的 div,所以只需停止该容器中的事件冒泡,一切都会正常工作。

来源: http://forum.jquery.com/topic/datepicker-propogates-click - 活动

I was facing same issue and fixed it by adding in document ready:

/*Stop datepicker from closing dropdown menu*/
    $("#ui-datepicker-div").click( function(event) {
        event.stopPropagation();
    });

the trick is that datepicker creates a div with id ui-datepicker-div so just stop event bubbling from that container and everything will work fine.

Source: http://forum.jquery.com/topic/datepicker-propogates-click-events

许久 2025-01-14 15:02:14

我通过修改代码解决了这个问题,以便菜单忽略来自日期选择器的任何点击。

I fixed the issue by modifying the code so that the menu ignores any clicks from the datepicker.

变身佩奇 2025-01-14 15:02:14

我遇到了同样的问题,首先,我也想停止事件气泡,因为,我单击日期选择器,它不起作用,输入类型是文件被触发(在日期选择器下方),它通过设置数据选择器 z 解决它-999 代码的索引

在这里:
datepicker.css('z-index', 999);

这对我有用

i meet the same problem, at first ,i also want to stop event bubble, because, i click date picker, it doesn't work, input type is file is fired(below date picker), it solve it by setting data picker z-index to 999

code is here:
datepicker.css('z-index', 999);

it works for me

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