jQuery datepicker中的事件冒泡 [英] event bubbling in Jquery datepicker
问题描述
我有一个弹出菜单,其中包含带有jquery datepicker的表单,问题是当我选择日期时,菜单和datepicker日历都会关闭.
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.
我试图在Select事件中为datepicker使用event.stopPropagation(),但是我找不到方法来获取事件"的句柄.
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".
此外,我试图在选择事件结束时返回false ,但再次失败了.任何帮助都感激不尽.谢谢.
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.
推荐答案
我也遇到了同样的问题,并通过添加文档就绪来解决它:
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();
});
诀窍是,datepicker会创建一个ID为ui-datepicker-div的div,因此只需停止从该容器中冒泡的事件,一切都会正常进行.
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.
来源: http://forum.jquery.com/topic/datepicker-传播点击事件
这篇关于jQuery datepicker中的事件冒泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!