[英]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.