Attempting to execute a function with two parameters in NuxtJS upon clicking an element using AddEventListener
.
async handleSubmit(recipe, userRating) {some code...}
setup(recipe) {
document.querySelectorAll('.recipe-rating > .star').forEach(function(el) {
el.addEventListener('click', function(el) {
const userRating = el.currentTarget.getAttribute('data-rating');
this.handleSubmit(recipe, userRating);
}, false);
});
...more code...
}
The entire code is enclosed within methods: {}
, but an error occurs when the click event triggers.
Uncaught TypeError: this.handleSubmit is not a function at SVGSVGElement.eval
How can I resolve this issue and identify what's causing it?