I have an HTML button with a data attribute:
<button data-shop-listing='{"name": "Towel", "description": "Sunny days and warm weather - you clearly need it after a refreshing jump into the cool sea.", "price": 10.00}'>Add to cart</button>
I want to access the data when the button is clicked using Kotlin. When the click event is triggered, I do this, where item is the HTML element that triggered the event.
fun addItemToCart (item:EventTarget?) {
console.log(item.dataset.shopListing)
}
However the compiler gives this error: "unresolved reference dataset".
These are my imports:
import org.w3c.dom.*
import org.w3c.dom.events.*
import kotlin.browser.*