jquery在下拉菜单和ajax窗口之间冲突 [英] jquery conflict between dropdown menu and ajax window
问题描述
尝试它,源代码在这里:
codepen.io / riogrande / pen / NxZLaQ
逐步复制:
-
鼠标悬停在最右边,Lorem和下拉菜单出现。
-
退出鼠标悬停,然后点击标题为点击此处查看ajax的链接
-
点击X退出ajax popover
-
步骤1不再有效。
p>您可以使用单独的 fadeIn
和 fadeOut
函数,而不是单个 fadeToggle
悬停,它会解决问题:
$(。menu-dropdown)。hover(
function(e){
if($(window).width()> 943){
$(this).children(ul)。stop(true,false) fadeIn(150);
e.preventDefault();
}
},
函数(e){
if($(window).width ; 943){
$(thi 。S)。儿童( UL)停止(TRUE,FALSE).fadeOut(150);
e.preventDefault();
}
}
);
CodePen 这里。
I have a jquery dropdown menu and an modal window which is a trigger for ajax. The problem occurs when you click on link for ajax, and when you close it dropdowns are not working anymore. So dropdown is working when you dont click the ajax. When you click the link and close it, dropdown menu is not showing dropdown.
Try it and source code are here:
codepen.io/riogrande/pen/NxZLaQ
Step by step to reproduce:
Mouse over the right most "Lorem" and a drop down menu appears.
Exit the mouseover and click the link titled "Click here for ajax"
Click the "X" to exit the ajax popover
Step 1 no longer works.
You can use separate fadeIn
and fadeOut
functions instead of a single fadeToggle
on hover and it will fix the issue:
$(".menu-dropdown").hover(
function(e) {
if ($(window).width() > 943) {
$(this).children("ul").stop(true,false).fadeIn(150);
e.preventDefault();
}
},
function(e) {
if ($(window).width() > 943) {
$(this).children("ul").stop(true,false).fadeOut(150);
e.preventDefault();
}
}
);
CodePen here.
这篇关于jquery在下拉菜单和ajax窗口之间冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!