@tpot in html this is < button id=“xyz” onclick=“someroutine”>
someroutine is in your javascript module.js handler
someroutine: function(){
the ‘this’ variable points to the button object that caused the call
this.id equals ‘xyz’
}
you can also create the button with code (in the getDom function)
let button = document.createElement(“button”)
button.id=‘xyz’;
button.addEventListener(‘click’,self.someroutine)
wrapper.appendChild(button)
here is a routine from another module to create a button object with an icon, and some data (src attribute) to be used when the button is pushed
createVideoButton: function(video, height, width) {
let button = document.createElement("button");
button.className = "button";
button.setAttribute("data-video-src", "modules/" + self.name + "/" + this.config.videoDir + "/" + video);
button.addEventListener("click", self.swapVideo);
let img = document.createElement("img");
img.src = "modules/" + self.name + "/" + this.config.posterDir + "/" + self.Hash[video.substring(0, video.indexOf('.'))];
img.width = width;
img.height = height;
button.appendChild(img);
return button;
},
swapVideo: function () {
Log.log("in handler for button="+this.getAttribute("data-video-src"));
self.player.src = this.getAttribute("data-video-src");
self.player.load();
self.player.controls = true;
self.player.play();
},