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

Action Button & Repeating Fields

Can an action button be used in a repeating section ?  I can't find any documentation about it.  Not saying said documentation is there, just that I have yet to find it. My current project is using an action button to open up a hide/show area (instead of a styled checkbox).  Simply adding "repeating_foo:" and  "repeating_foo_" to the associated sheet workers doesn't change anything; the button is not visible.
1592855922
GiGs
Pro
Sheet Author
API Scripter
Action buttons can be used in repeating sections. Can you post the sheet worker, and the relevant the css and part of the repeating section?
1592863976

Edited 1592864029
Coal Powered Puppet
Pro
Sheet Author
html <fieldset class="repeating_spells">     <!-- Extra crap removed -->     <div class="sheet-row"> <div class="item 40">     <input type="hidden" class="direction" name="attr_spell_expand" value="right" />     <button type="action" class="direction" name="act_spell_expand_toggle" >         <span class="down">▼</span>         <span class="right">►</span>     </button> </div>     </div>     <input type="hidden" class="direction" name="attr_spell_expand" value="right" />     <span class="hide_2">Stuff</span> </fieldset> And the css /*-----showhide-----*/ /*-----showhide-----*/ button.sheet-direction { margin: 0; overflow: visible; text-transform: none; border-style: none; padding: 0; background: transparent; cursor: pointer; outline-style: none; } /* Hide the section(s) that do not match the attribute value */ input.sheet-direction:not([value="down"]) + button.sheet-direction > span.sheet-down { display: none; } input.sheet-direction:not([value="right"]) + button.sheet-direction > span.sheet-right { display: none; } /* Hide the section(s) that do not match the attribute value */ input.sheet-direction:not([value="right"]) ~ span.sheet-hide_1 { display: none; } input.sheet-direction:not([value="down"]) ~ span.sheet-hide_2 { display: none; }
1592864253
GiGs
Pro
Sheet Author
API Scripter
What about the sheet worker?
Brain fart. on("clicked:repeating_spells:spell_expand_toggle", function() { // Check the current value of the hidden attribute. getAttrs(["repeating_spells_spell_expand"], function(v) { // Toggle the hidden attribute value between "down" and "right" setAttrs({ "repeating_spells_spell_expand": v["repeating_spells_spell_expand"] !== "down" ? "down" : "right" }); }); });
1592867130

Edited 1592870234
GiGs
Pro
Sheet Author
API Scripter
This was a tricky one. You had two problems, and it looks like one is a bug with roll20. If you have an underscore in the button name, it doesnt get triggered. I changed this act_spell_expand_toggle to  act_spell-toggle to get it working. There's a similar problem with repeating section names, which cant have a second underscore either.  The second problem is, action buttons dont get the row id automatically, so you need to supply it using the eventInfo object. Here's code that works, assuming you rename the button as above:     on("clicked:repeating_spells:spell-toggle", function(eventInfo) {         // Check the current value of the hidden attribute.         const rowid = eventInfo.sourceAttribute.split('_')[2];         getAttrs([`repeating_spells_${rowid}_spell_expand`], function(v) {           // Toggle the hidden attribute value between "down" and "right"           setAttrs({             [`repeating_spells_${rowid}_spell_expand`]: v[`repeating_spells_${rowid}_spell_expand`] !== "down" ? "down" : "right"           });         });     }); Note that if this looks unfamiliar: `repeating_spells_${rowid}_spell_expand` it's just the same as doing this: "repeating_spells_" + rowid + "spell_expand" eventInfo works like values in getAttrs, and gives you a bunch of properties you can access. One is eventInfo.sourceAttribute That gives you the full name of the button clicked, like so console.log(eventInfo.sourceAttribute); // gives: "repeating_spells_-M8Ja-GEzzNL4B3taRYD_spell-toggle" We can use split("_") to turn that into an array, and split("_")[2] gives the row id. It's all a bit more complicated than it needs to be. It's a shame it doesnt work as smoothly as attributes.
1592870338
GiGs
Pro
Sheet Author
API Scripter
Note: in case you already grabbed the code above. I had a typo on the first line, which should be on("clicked:repeating_spells:spell-toggle", function(eventInfo) { It's fixed now.
1592882368
vÍnce
Pro
Sheet Author
GiGs said: This was a tricky one. You had two problems, and it looks like one is a bug with roll20. If you have an underscore in the button name, it doesnt get triggered. I changed this act_spell_expand_toggle to&nbsp; act_spell-toggle to get it working. This has tripped me up more than once... I just updated the wiki to help avoid this pitfall:&nbsp; <a href="https://wiki.roll20.net/Button#Action_Button" rel="nofollow">https://wiki.roll20.net/Button#Action_Button</a>
1592883191
GiGs
Pro
Sheet Author
API Scripter
Good thinking. I was planning to update the wiki, but had to leave the PC for a while then forgot about it.
Yawl are awesome.,&nbsp; This works great.&nbsp; Thank you both.