I have the following code to display a dialog with three buttons. I'm trying to execute a specific function depending on the button clicked. However so far I have had no luck in getting the functions to execute:
this.myMarkers.push({
latitude: val["Latitude"],
longitude: val["Longitude"],
title: 'Tree ' + val["TreeID"],
custom: {id: 123456},
infoWindow: {content: `
<div id="content">
<div id="siteNotice"></div>
<h1 id="firstHeading" class="firstHeading">Tree ${val["TreeID"]}</h1>
<div id="bodyContent">
<p>Description: ${val["Description"]}</p>
<p>Fruit Bearing: ${val["FruitBearing"]}</p>
<button type="button" onclick="this.updateTree()">Update</button>
<button type="button" onclick=${this.editTreeInfo()}>Edit Info</button>
<button type="button" onclick="${this.showTreeHistory()}">Historical</button>
</div>
</div>`}
});
updateTree(){
console.log("Update Tree: ");
}
editTreeInfo(){
console.log("Edit Tree: ");
}
showTreeHistory(){
console.log("Show Tree History: ");
}
In the console, after the page loads, the following is outputted:
welcome.js:56 Edit Tree:
welcome.js:60 Show Tree History:
welcome.js:56 Edit Tree:
welcome.js:60 Show Tree History:
welcome.js:56 Edit Tree:
welcome.js:60 Show Tree History:
welcome.js:56 Edit Tree:
...
And when clicking the buttons, nothing happens - except for:
Uncaught TypeError: this.updateTree is not a function
at HTMLButtonElement.onclick ((index):1)
Nothing happens for the other buttons. I have tried using click.delegate
but this doesn't seem to do anything either.