class OptionsTableViewCell extends TableViewCell { build(element) { element = super.build(element); this.optionsButton = document.createElement("button"); this.optionsButton.className = "options"; this.optionsButton.addEventListener("click", this.onOptionsButtonPressed.bind(this)); element.appendChild(this.optionsButton); return element; } setData(data) { super.setData(data); if (data.contextMenu) { this.contextMenu = data.contextMenu; } } onOptionsButtonPressed(event) { this.contextMenu.cell = this; this.contextMenu.showForElement(this.optionsButton, "right"); //Stop the event from getting propagated because this might hide the context menu again immediately or cause a click on the item itself. event.stopPropagation(); } } UIKit.registerViewType(OptionsTableViewCell);