Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Problem with button-based tabs

1624273782

Edited 1624274098
Rondragos
Pro
Sheet Author
Hello there! I'm pretty sure there is just a small mistake, but I just can't find it. In short: the content that should be shown when the buttons are clicked just doesn't show. I'm trying to create a custom character sheet for a crossover classic World of Darkness game I'm GMing, based on the 20th anniversary VtM sheet. I want to use some styling and possibly a lot of snippets, but building it from scratch to understand the whole code and don't use tables for layout. I'm not very experienced in html and a lot less in CSS, but I see this as an opportunity to change this. Right now, I'm trying to implemet different tabs, using the action button based tabs from the CSS Wizardry page in the wiki, but they just don't seem to work and I have no idea why not. Since my sheet isn't a lot more than this I'll post anything I have this far: &lt;div class="main border-div"&gt; &lt;!-- Immer sichtbare Überschriftzeile --&gt; &lt;div class="logo logo-div"&gt;&lt;/div&gt; &lt;div class="ltop"&gt; &lt;/div&gt; &lt;div class="rtop"&gt; &lt;/div&gt; &lt;!-- Menu --&gt; &lt;div class="tabselect"&gt; &lt;button type="action" name="act_primary"&gt;Primary&lt;/button&gt; &lt;button type="action" name="act_backgrounds"&gt;Backgrounds&lt;/button&gt; &lt;button type="action" name="act_powers"&gt;Powers&lt;/button&gt; &lt;button type="action" name="act_experience"&gt;Experience&lt;/button&gt; &lt;button type="action" name="act_notes"&gt;Notes&lt;/button&gt; &lt;/div&gt; &lt;input type="hidden" class="sheet-tabstoggle" name="attr_sheettab" value="primary" /&gt; &lt;!-- Hauptbogen --&gt; &lt;!-- &lt;div class="common"&gt;--&gt; &lt;!-- Primary Sheet --&gt; &lt;div class="common sheet-primary"&gt; &lt;h2&gt;Primary&lt;/h2&gt; &lt;span&gt;Here will be traits&lt;/span&gt; &lt;/div&gt; &lt;!-- Background Sheet --&gt; &lt;div class="common sheet-background"&gt; &lt;h2&gt;Background&lt;/h2&gt; &lt;span&gt;Here will be traits and descriptions&lt;/span&gt; &lt;/div&gt; &lt;!-- Powers Sheet --&gt; &lt;div class="common sheet-powers"&gt; &lt;h2&gt;Powers&lt;/h2&gt; &lt;span&gt;Here will be special traits&lt;/span&gt; &lt;/div&gt; &lt;!-- Experience Sheet --&gt; &lt;div class="common sheet-experience"&gt; &lt;h2&gt;Experience&lt;/h2&gt; &lt;span&gt;Here will be experiences&lt;/span&gt; &lt;/div&gt; &lt;!-- Notes Sheet --&gt; &lt;div class="common sheet-notes"&gt; &lt;h2&gt;Notes&lt;/h2&gt; &lt;span&gt;Here will be notes&lt;/span&gt; &lt;textarea&gt;Some text&lt;/textarea&gt; &lt;/div&gt; &lt;!-- &lt;/div&gt; --&gt; &lt;/div&gt; &lt;script type="text/worker"&gt; const buttonlist = ["primary", "backgrounds", "powers", "experience", "notes"]; buttonlist.forEach(button =&gt; { on(`clicked:$(button)`, function() { setAttrs({ sheettab: button }); }); }); &lt;/script&gt; And /*Border and Logo */ .border-div { background-color:transparent; border-style: solid; border-width: 40px 30px 30px; border-image-source: url(<a href="http://i.imgur.com/hjjMqek.png" rel="nofollow">http://i.imgur.com/hjjMqek.png</a>); border-image-slice: 75 56 58 54; border-image-repeat: round stretch; } .logo-div { background-image: url(<a href="https://upload.wikimedia.org/wikipedia/commons/9/9e/World_of_Darkness_Online_logo.svg" rel="nofollow">https://upload.wikimedia.org/wikipedia/commons/9/9e/World_of_Darkness_Online_logo.svg</a>); background-size:100% 140px; background-repeat: repeat-x; background-position: 0px 10px; } /*Main-Layout Grid*/ .main { display: grid; grid-template-columns: minmax(10%, 1fr) minmax(140px, 566px) minmax(10%, 1fr); grid-template-rows: minmax(35px, 140px) 80px 1fr; grid-template-areas:"ltop logo rtop" "tabselect tabselect tabselect" "common common common"; } .ltop { grid-area: ltop; background-color: orange; } .rtop { grid-area: rtop; background-color: orange; } .logo { grid-area: logo; background-color: yellow; } .tabselect { grid-area: tabselect; background-color: olive; } .common { grid-area: common; background-color: magenta; } /*Configuration of tab Buttons*/ .sheet-primary, .sheet-background, .sheet-powers, .sheet-experience, .sheet-notes { display: none; } /*show the selected tab*/ .sheet-tabstoggle[value="primary"] ~ div.sheet-character, .sheet-tabstoggle[value="background"] ~ div.sheet-background, .sheet-tabstoggle[value="powers"] ~ div.sheet-powers, .sheet-tabstoggle[value="experience"] ~ div.sheet-experience, .sheet-tabstoggle[value="notes"] ~ div.sheet-notes { display: block; } ((the coloring is there to better see the spaces within the CSS grid and surely won't be there forever)) Please, can somebody tell me what is wrong? I see the buttons but it doesn't show any of the content of the tabs.
1624288718
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Your problem is in your sheetworker: buttonlist.forEach(button =&gt; { on(`clicked:$(button)`, function() { setAttrs({ sheettab: button }); }); }); the $(button) is incorrect. To reference a variable in a template literal, you use ${...}. Like so: buttonlist.forEach(button =&gt; { on(`clicked:${button}`, function() { setAttrs({ sheettab: button }); }); });
1624307973

Edited 1624308066
Rondragos
Pro
Sheet Author
Thank you so much! I knew it had to be a really small mistake. I'm so blind... Edit: Also had a small spelling mistake in 2 of those 5 pages (especially the first, so that explains that even the default page wasn't shown) but now it works!