I'm unable to access a private method that was used as an argument for a submitted event. The use of this
now points to the form rather than the class itself. what is the easiest way to reference a class irrespective of object depth or closure in javascript?
class payment {
#form;
constructor() {
this.#form = $('#code-form').get(0);
this.#form.addEventListener('submit', this.#submitForm);
}
#submitForm(e) {
e.preventDefault();
console.log( this.#form ); // Cannot read private member #form from an object whose class did not declare it
}
}
(new payment());