I have a bespoke widget that adds a GeoJson layer to a mapview.
When the map is clicked and features from the GeoJson layer are identified they are loaded back into the widget UI as the list of features selected.
The UI output is made like this:
let message = response.results.length + " Feature selected here.<br \>";
for(let index = 0; index < response.results.length; ++index){
message += "ID: " + response.results[index].graphic.attributes.feature_id + ":<br \>";
message += "Date: " + response.results[index].graphic.attributes.date_time + "<br \>";
message += '<Button onClick="getDetails(\'' + response.results[index].mapPoint.latitude.toFixed(4) + ', ' + response.results[index].mapPoint.longitude.toFixed(4))" size="default">Load</Button>';
}
All this loads into the UI fine but the scope on the button onClick fails with this message:
Uncaught ReferenceError: getDetails is not defined
at HTMLButtonElement.onclick (0/?draft=true:1:1)
onclick @ 0/?draft=true:1
Sorry but lost as to how I can get scope back on the button click, tried so many approaches and just more confused now.