I've come across some situations where I don't know how many sets of tab will be on a page, and so have to loop over all instances of [data-tabs] to initialize a Tabby for it. I've achieved this with..
const ELEMENTS = document.querySelectorAll("[data-tabs]");
if (ELEMENTS.length > 0) {
ELEMENTS.forEach((element) => {
new Tabby(`#${element.getAttribute("id")}`);
});
}
but that seems somewhat fragile and also confusing to read. Being able to directly pass element in this case would really simplify things.
I've come across some situations where I don't know how many sets of tab will be on a page, and so have to loop over all instances of
[data-tabs]
to initialize a Tabby for it. I've achieved this with..but that seems somewhat fragile and also confusing to read. Being able to directly pass
element
in this case would really simplify things.