【发布时间】:2016-10-03 17:35:06
【问题描述】:
我使用 jQuery 版本 2.2.4 并尝试捕获事件 - 不走运。有什么办法可以解决问题吗?
此代码有效:
window.addEventListener('test.namespace', e => console.log('CustomEvent with namespace captured by vanilla'));
这不起作用:
$(window).on('test.namespace', e => console.log('CustomEvent with namespace captured by jQuery'));
const event = new CustomEvent('test.namespace', {
bubbles: true,
detail: 123
});
window.dispatchEvent(event);
【问题讨论】:
标签: javascript jquery namespaces jquery-events custom-events