Im making a Firefox Addon in FF42 using the Addon SDK. I've also included an AngularJS app in the Addon, and in the app.js file, I've created an Event Listener as so
我正在用Addon SDK制作一个FF42中的Firefox插件。我还在Addon中包含了一个AngularJS应用程序,在app.js文件中,我也创建了一个事件监听器
window.addEventListener("updateSimpleStorage", function($obj) {
console.log('updateSimpleStorage: ', $obj);
private_self_options.simpleStorage = $obj.detail;
});
and in my script.js I am sending out an Event as so
并在我的脚本。我正在发送一个事件
var e = new CustomEvent('updateSimpleStorage', {'detail': simpleStorage});
window.dispatchEvent(e);
So why is it that the eventlistener doesnt pick up on the event? Please point out my mistake? I feel its a scope issue but I cant put my finger on it.
那么,为什么eventlistener没有注意到这个事件呢?请指出我的错误。我觉得这是一个范围的问题,但我说不清楚。
1 个解决方案
#1
2
There is a 3rd and 4th argument to addEventListener
.
对于addEventListener来说有第三和第四种争论。
The 3rd one you are familiar with, its the useCapture
. The 4th one is criticial in this case, because you want to capture events from unprivileged code. So you must set that to true
.
第三个你熟悉的,它的使用。第四个在这里是criticial,因为你想从无特权的代码中捕获事件。所以你必须让它为真。
See these topics:
看到这些主题:
- How to listen to custom events on all windows, bubbling issue?
- 如何侦听所有窗口上的自定义事件、冒泡问题?
- https://*.com/a/25822988/1828637
- https://*.com/a/25822988/1828637
#1
2
There is a 3rd and 4th argument to addEventListener
.
对于addEventListener来说有第三和第四种争论。
The 3rd one you are familiar with, its the useCapture
. The 4th one is criticial in this case, because you want to capture events from unprivileged code. So you must set that to true
.
第三个你熟悉的,它的使用。第四个在这里是criticial,因为你想从无特权的代码中捕获事件。所以你必须让它为真。
See these topics:
看到这些主题:
- How to listen to custom events on all windows, bubbling issue?
- 如何侦听所有窗口上的自定义事件、冒泡问题?
- https://*.com/a/25822988/1828637
- https://*.com/a/25822988/1828637