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

on("clicked:action_button" and repeating sections

1553410047
vÍnce
Pro
Sheet Author
Can anyone confirm that action buttons that reside within a fieldset cannot be used as a sheetworker listener?&nbsp; I'm trying to use a Charmancer Action button:&nbsp; <a href="https://wiki.roll20.net/Charactermancer_Development_Documentation#clicked:.3Caction_button_name.3E" rel="nofollow">https://wiki.roll20.net/Charactermancer_Development_Documentation#clicked:.3Caction_button_name.3E</a> &nbsp;within a repeating section to trigger some attribute changes. example; sheetworker's can detect&nbsp; on("clicked:action_button" but not&nbsp; on("clicked: repeating_foo: action_button" If this is true, wouldn't it be worthwhile that&nbsp;on("clicked: behaved like the other listeners?
1553419946
Kavini
Roll20 Production Team
Marketplace Creator
Sheet Author
Compendium Curator
I have managed to get this working by using on("clicked:repeating_foo") without identifying the action button in specific, this obviously limits you to one action button per repeating section entry.
1553420625

Edited 1553420641
vÍnce
Pro
Sheet Author
Thanks Nic.&nbsp; That might actually work for my particular use case. (of course after I just spent an hour working up a fake action button... lol)&nbsp; Any chance we might get the on("clicked) listener to work "within" a repeating section? Thanks
1553422827
Kavini
Roll20 Production Team
Marketplace Creator
Sheet Author
Compendium Curator
Unfortunately, this isn't at all my area, I'm just scrabbling around making character sheets as a hobbiest like everyone else here. That said, I will pass it on :)
1553448492

Edited 1553448635
vÍnce
Pro
Sheet Author
Thanks Nic Maybe the wiki should get a comment as well...&nbsp; I'm happy to add something unless the page is only editable by roll20.
1553531985

Edited 1553540378
Caden
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Greetings Vince, Action buttons can be found in a repeating section like the example below. This issue in your example would be in using the extra underscore in ("clicked:repeating_foo:action_button"... &nbsp;in retrospect I do not know off the top of my head if an additional _ was the problem. &nbsp;&nbsp;&nbsp;&nbsp;on("clicked:repeating_quality:quality", (eventinfo) =&gt; { const source = (eventinfo.sourceAttribute).slice(0, -8); getAttrs([`${source}_flag_quality`], (v) =&gt; { setAttrs({ [`${source}_flag_quality`]: (v[`${source}_flag_quality`] === "settings") ? "display" : "settings" }); }); });&nbsp;
1553551822
vÍnce
Pro
Sheet Author
Thanks Nic and Cassie.&nbsp; I'll need to play around with it again.&nbsp; Maybe later tonight. In the meantime, I ended up just making one of those input+span "mock" buttons and triggering off of that.&nbsp; But the simplicity of the action button for such events is very nice.
1553561112
Caden
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Greeting Vince, I've been converting all my sheets. My Warhammer 40k Wrath &amp; Glory sheet use them a LOT for the dice roller. I can provide more examples and try to help with further questions. They are sooooooo nice for getting rid of excess tedious code that the fake span buttons need.&nbsp; - Cassie
1553724326

Edited 1553730567
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Vince, I ran into this issue myself recently while working on the SF sheet. In the repeating section that you have your action button in, do you have a containing div that has a position property applied to it? Something like this (bolded): HTML &lt;div class='buffs'&gt; &lt;!-- contains the buffs repeating section--&gt; &lt;fieldset class='repeating_section'&gt; &lt;div class='filter-container'&gt; &lt;button type='action' name='act_button'&gt;Button&lt;/button&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;/div&gt; CSS .repcontainer div{ position:relative; } Javascript used to test &lt;script type='text/worker'&gt; on('clicked:repeating_section:mod', (event)=&gt;{console.log(`clicked:repeating_section:mod event: ${JSON.stringify(event)}`)});//This event will only be triggered if position:relative/absolute is NOT applied to the filter-container div. on('clicked:mod', (event)=&gt;{console.log(`clicked:mod event: ${JSON.stringify(event)}`)});//This event will only be triggered if position is applied to the filter-container div. However it will not have repeating row info. &lt;/script&gt; After eliminating code line by line until the events started firing correctly, I found that if you have a div with position:relative &nbsp;or absolute applied to it the event doesn't fire correctly. Position:static &nbsp;doesn't appear to cause the issue, but I have by no means tested all the possible position states. I also have no clue why a css position change would affect how a javascript event is passed since it certainly doesn't affect any other event generation in the sheetworker environment.
1553727977

Edited 1553727992
vÍnce
Pro
Sheet Author
Who would have thought a child element's position would interfere with the js detection?&nbsp; I'm still working on higher priority tasks ATM, but I will revisit this, since I'm primarily using action buttons on the sheet to add "presets" to a dice pool.&nbsp; Thanks Scott
1553730216
GiGs
Pro
Sheet Author
API Scripter
Have you raised that as a bug, Scott?
1553730522
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, I've brought it up.
1553730825
GiGs
Pro
Sheet Author
API Scripter
Great. It is such a weird bug.
1553975468

Edited 1626830170
vÍnce
Pro
Sheet Author
I finally got back around to this... SOLVED: Cassie's thought concerning the "_" within the button name was preventing the button from being properly detected by the sheet worker. Button name's containing an underscore e.g "attack_roll"&nbsp; inside a repeating section, ARE NOT DETECTED by the&nbsp;on("clicked:&nbsp;listener. Once I changed the name to "attack-roll", suddenly the listener worked as expected.&nbsp; It appears you can use an underscore in your button name&nbsp; outside of a repeating section, but not inside a repeating section. Seems a little buggy to me. Thanks for the help everyone.