简体   繁体   English

未调用事件On元素,但我可以确认它们已附加

[英]Events On element not being called, but I can confirm that they have been attached

Sorry in advance that I don't have nice short code examples to display with this post. 预先抱歉,我没有与此帖子一起显示的简短示例。 I'm running into a really weird problem in an app i'm developing. 我正在开发的应用程序遇到一个非常奇怪的问题。 I wrote some custom scrollbar code, and in this one instance none of the event handlers I add to one of the scroll bar "handles" are getting called. 我编写了一些自定义滚动条代码,在这种情况下,没有一个我添加到滚动条“句柄”之一的事件处理程序被调用。

You can see the app here 你可以在这里看到应用程序

To see the problem just search for "biology" in the top left, and select the first result. 要查看问题,只需在左上方搜索“生物学”,然后选择第一个结果。 Wait for some results to load in the right pane. 等待一些结果加载到右窗格中。 The scroll bar in the right pane for "new" shouldn't respond to mouse clicks. 右侧窗格中“新”的滚动条不应响应鼠标单击。 If you switch to the used tab it will. 如果切换到使用的选项卡,它将显示。

Now before you think I messed up attaching the event to it, try this. 现在,在您认为我不喜欢将事件附加到它之前,尝试一下。

If you are using chrome or anything with an easy javascript console you can run 如果您使用的是chrome或带有简单javascript控制台的任何内容,则可以运行

$('.bs-scroll_bar_handle').mousemove(function(){console.log('moved');});

Now every time you move your mouse over one of the scroll bars it should log "moved". 现在,每次将鼠标移到其中一个滚动条上时,它都应该记录为“已移动”。 It works on the used tab, in the search results, but not under new. 它适用于搜索结果中“二手”标签,但不适用于“新标​​签”。

I've used Visual Event to confirm that the event handler is getting added to the element, and I can manually trigger it using Visual Event. 我已经使用Visual Event确认事件处理程序已添加到元素中,并且可以使用Visual Event手动触发它。

One other note. 另一注。 If I only create the New tab and not the used one, it will function correctly. 如果我仅创建“新建”选项卡而不创建已使用的选项卡,则它将正常运行。

Even if you can't find the exact problem I would really appreciate suggestions for why this might be happening. 即使您找不到确切的问题,我也非常感谢您提出可能会发生这种情况的建议。

Thanks! 谢谢!

All your code looks good, you just need to add a z-index: 999; 您所有的代码看起来都不错,您只需要添加一个z-index: 999; to the inline elements style on the scroll bar that is not working: 到无效的滚动条上的内联元素样式:

<div class="bs-scroll_bar_handle" style="visibility: visible; height: 310px; top: 0px; z-index: 999;"></div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在单个元素的 javascript 中有 3 个事件吗? - Can I have 3 events in javascript in single element? 如何确定哪些事件附加到元素上以及这些事件触发哪些功能? - How can I determine which events are attached to an element, and which functions those events trigger? 萤火虫-如何检测已调用的函数或从何处调用了函数 - firebug - how can I detect what functions have been called or from where a function has been called 即使在被调用后也期望被调用失败 - Expect to have been called failing even after being called 如何仅使用JavaScript,不使用框架来访问绑定到dom元素的事件 - How do I access what events have been bound to a dom element using only JavaScript, no frameworks 我可以在一个元素中有两个 JavaScript onclick 事件吗? - Can I have two JavaScript onclick events in one element? 我可以在一个元素中包含2个JavaScript onClick事件吗? - Can I have 2 JavaScript onClick events in a single element? 我们如何找到附加到 DOM 元素的所有事件 - How can we find all the events attached to a DOM element 由于我已将mouseover和mouseout事件附加到HTML中的每个元素,如何在几个HTML元素上阻止相同的事件? - Since I have attached mouseover and mouseout event to each and every element in HTML, How can I prevent same event on few HTML element? 在离开网页时,我可以使用什么工具找出正在调用的JavaScript事件? - What tool can I use to find out what JavaScript events are being called when leaving a web page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM