简体   繁体   English

如何找出防止事件冒泡的地方?

[英]How to find out where the event is prevented from bubbling up?

I have a form and I try to submit it but nothing happens. 我有一个表单,我尝试提交它但没有任何反应。 I can see $('#myform').submit() gets called but then nothing happens. 我可以看到$('#myform')。submit()被调用但是没有任何反应。 I'm guessing that somewhere the submit event is getting caught 'silenced'. 我猜这个提交事件的某个地方被“沉默”了。 Is there a way for me to find out where this event gets caught? 有没有办法让我找出这个事件被抓到的地方?

update Darin Dimitrov suggestion helped me to figure out where exactly submit is handled. 更新 Darin Dimitrov建议帮助我弄清楚究竟提交的处理方式。 I was able log handlers for submit events. 我能够为提交事件记录处理程序。 Then I set break points inside of the handlers and stepped through code to figure out where my submit process was being 'cancelled'. 然后我在处理程序内设置断点并逐步执行代码以确定我的提交过程被“取消”的位置。 ps I'm looking at log and debugging in firebug of course. ps我当然在看firebug中的日志和调试。

在此输入图像描述

To find out which submit event handlers are registered to your form you could use the following to print them to the console: 要找出哪些提交事件处理程序已在表单中注册,您可以使用以下内容将它们打印到控制台:

$.each($('#myform').data('events').submit, function(key, value) {
    console.log(value.handler);
});

This obviously assumes that those event handlers have been registered with jQuery. 这显然假设那些事件处理程序已经注册了jQuery。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM