I’m not sure how you are meant to display a popup, so I tried to make right click work. Is this what you want?

Regardless of that, the issue is with addrPopup
, there’s a line that 136 that has something like this:
addrPopup.prototype._applyValues = () => {
Arrow function does not have this
, so anything inside it is pointed to the nearest this
, which is basically undefined
.
Change it to:
addrPopup.prototype._applyValues = function() {
Edit: also, at line 133, you have
// this.applyButton.addEventListener('click', this._applyValues(this.params));
.addEventListener
2nd parameter should be a function, and in the commented code, it’s getting a result of a function call (this._applyValues(this.params)
), which may or may not be a function.
Change it to:
this.applyButton.addEventListener('click', () => this._applyValues(this.params));
Here’s another issue: we need to remove these listener when disposing an addrPopup
instance. So you will need to do something like this:
function addrPopup() {
this.applyBtnClickListener = () => this._applyValues(this.params);
}
...
...
this.applyButton.addEventListener('click', this.applyBtnClickListener);
so later when destroying the popup, you can do:
this.applyButton.removeEventListener('click', this.applyBtnClickListener);
and it should work. My updated example here https://gist.dumber.app/?gist=6c41513f56de50c6c6f5d598290a470d
Thanks @huochunpeng for making it easy to share these gist 