Skip to content

Instantly share code, notes, and snippets.

@werpu
Created April 19, 2020 17:33
Show Gist options
  • Select an option

  • Save werpu/e230b8bcf82fdc3b67a748d97f368684 to your computer and use it in GitHub Desktop.

Select an option

Save werpu/e230b8bcf82fdc3b67a748d97f368684 to your computer and use it in GitHub Desktop.
TagBuilder.withTagName("x-navigation")
.withMarkup("<button id='nav_c64' data-target='c64'>C64</button><button id='atari5200' data-target='atari5200'>Atari 5200</button><button id='coleco-1p' data-target='coleco-1p'>Colecovision</button>")
.withConnectedCallback(function () {
DomQuery.querySelectorAll("x-navigation button").addEventListener("click", (evt) => {
let target = evt.target.dataset["target"];
location.href = target + '.html';
}).each((item => {
item.removeClass("hidden");
if (item.attr("data-target").value == DomQuery.byId(this).attr("selected").value) {
item.addClass("hidden");
}
}));
})
.register();
@edburns

edburns commented Apr 19, 2020

Copy link
Copy Markdown

That is pretty gnarly, but you gotta do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment