I have a mapbox popup with a button inside it that I want to trigger a method from my Vue component.
This is how I set up my popup:
const popup = new mapboxgl.Popup({ focusAfterOpen: false })
.setLngLat(coordinates)
.setHTML('<button id="button" @click="myMethod">Click here!</button>')
.addTo(map);
The method in my Vue component looks like this:
myMethod() {
console.log("clicked");
},
I successfully added an event listener to the button, but the function defined in my Vue component doesn't execute when the button is clicked.
This is my event listener setup:
var button = document.getElementById("button");
button.addEventListener("click", function() {
console.log("clicked");
});