event bubbling in Jquery datepicker

☆樱花仙子☆ 提交于 2019-12-11 11:55:26

问题


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.


回答1:


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




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/9368324/event-bubbling-in-jquery-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!