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

issue binding an on change event inside a repeating section

1579385989

Edited 1579435299
EDIT: Closed script tag I have a dropdown in a repeating section ("repeating_spellbookpetty") like below <fieldset class="repeating_spellbookpetty">     <select class="sheet-center sheet-spell-name" name="attr_spellname">         <option>Animal Friend</option> <option>Bearings</option>     </select> </fieldset> I cannot for the life of me get the following event to fire from this dropdown when it's changed.  Can anyone see any issue with it? <script type="text/worker"> on("change:repeating_spellbookpetty:spellname", function(eventInfo) { console.log(eventInfo); }); </script>
1579395683
John D.
Pro
Sheet Author
Your options have no value, so they never change! ;) Each option should be assigned a unique value, such as: <option selected=1>Animal Friend</option>
1579396398
vÍnce
Pro
Sheet Author
John D. said: Your options have no value, so they never change! ;) Each option should be assigned a unique value, such as: <option selected=1>Animal Friend</option> Just to add to John's comment; make sure to include the value within quotes.  The "selected" attribute assigns a default value. example; <option value="1" selected>Animal Friend</option>
Hi Guys, Thanks for the replies. Normally in the HTML standard spec, if no value is assigned then the text is the value. I omitted these because the dropdowns are massive and the values are the same as the text so the duplication seemed unnecessary. <a href="https://html.spec.whatwg.org/multipage/forms.html#the-option-element" rel="nofollow">https://html.spec.whatwg.org/multipage/forms.html#the-option-element</a> The&nbsp; value &nbsp;attribute provides a value for element. The&nbsp; value &nbsp;of an&nbsp; option &nbsp;element is the value of the&nbsp; value &nbsp;content attribute, if there is one, or, if there is not, the value of the element's&nbsp; text &nbsp;IDL attribute. <a href="https://www.w3.org/wiki/HTML/Elements/option" rel="nofollow">https://www.w3.org/wiki/HTML/Elements/option</a> value The content of this attribute represents the value to be submitted with the form, should this option be selected.&nbsp;If this attribute is omitted, the value is taken from the text content of the option element. Unless it works differently in roll20 for some reason? I've tried a version where I also assigned the values as well but it didn't work either.&nbsp;&nbsp; It may be worth mentioning that the repeaters are in tabs that may not be rendered/visible on page load. I wonder if something funky is happening where it's not binding the events to the fields because they're not on the DOM when the sheet loads. I'll keep playing around with it.
1579414717

Edited 1579415014
vÍnce
Pro
Sheet Author
Pete L. said: I cannot for the life of me get the following event to fire from this dropdown when it's changed.&nbsp; Can anyone see any issue with it? &lt;script type="text/worker"&gt; on("change:repeating_spellbookpetty:spellname", function(eventInfo) { console.log(eventInfo); }); &lt;/script &gt; Don't laugh; &lt;/script &gt; needs to be&nbsp;&lt;/script&gt; Pete L. &nbsp;said: Hi Guys, Thanks for the replies. Normally in the HTML standard spec, if no value is assigned then the text is the value. I omitted these because the dropdowns are massive and the values are the same as the text so the duplication seemed unnecessary. <a href="https://html.spec.whatwg.org/multipage/forms.html#the-option-element" rel="nofollow">https://html.spec.whatwg.org/multipage/forms.html#the-option-element</a> The&nbsp; value &nbsp;attribute provides a value for element. The&nbsp; value &nbsp;of an&nbsp; option &nbsp;element is the value of the&nbsp; value &nbsp;content attribute, if there is one, or, if there is not, the value of the element's&nbsp; text &nbsp;IDL attribute. <a href="https://www.w3.org/wiki/HTML/Elements/option" rel="nofollow">https://www.w3.org/wiki/HTML/Elements/option</a> value The content of this attribute represents the value to be submitted with the form, should this option be selected.&nbsp;If this attribute is omitted, the value is taken from the text content of the option element. Unless it works differently in roll20 for some reason? I've tried a version where I also assigned the values as well but it didn't work either.&nbsp;&nbsp; It may be worth mentioning that the repeaters are in tabs that may not be rendered/visible on page load. I wonder if something funky is happening where it's not binding the events to the fields because they're not on the DOM when the sheet loads. I'll keep playing around with it. I've never seen the option of the select written without a value(granted I'm hobbyist...),&nbsp; &nbsp;Thanks for sharing that.&nbsp; That said, I'm not sure how roll20 will parse it.&nbsp; Probably best to be safe and include it.&nbsp; You'll find that roll20 can be "finicky" about what it requires of html, css and js.&nbsp; Cheers
1579431855
GiGs
Pro
Sheet Author
API Scripter
Pete L. said: Normally in the HTML standard spec, if no value is assigned then the text is the value. I omitted these because the dropdowns are massive and the values are the same as the text so the duplication seemed unnecessary. Unless it works differently in roll20 for some reason? I've tried a version where I also assigned the values as well but it didn't work either.&nbsp;&nbsp; It doesn't work differently in roll20. There's a bunch of differences in roll20 to standard html to be wary of, but this isn't one of them.&nbsp; Vince has spotted the problem:&nbsp; Vince &nbsp;said: Don't laugh; &lt;/script &gt; needs to be&nbsp;&lt;/script&gt;
Hi Guys, Unfortunately I just typed that out as an example in haste, in the actual version the script tag is closed properly - I've updated the original post to reflect this. I'm convinced it's something to do with the tab visibility when the sheet loads because i'm out of ideas.&nbsp; Going to try and modify the display to hidden instead of none in the css when I get a chance tonight but I have some real work to finish first. but as far as anyone can see the text for the binding is correct? Thanks.
1579435905

Edited 1579436115
GiGs
Pro
Sheet Author
API Scripter
What is your code for the tabs? Tab visibility shouldnt make a difference-&nbsp; the entire sheet (including tabs) is loaded and accessible to scripts, before it is rendered on screen. Your code looks right - I also copied it into a blank sheet and it worked for me.
1579436020
GiGs
Pro
Sheet Author
API Scripter
Do you have any other script blocks, or any other code in your script block? If there's a syntax error before this script, than the code might be failing before it reaches the code above.
I've tried putting it at the top of the script block but no luck, there's a ton of javascript in the block (we're just editing an existing sheet) and we're pretty sure that all those functions/events are working. With normal javascript, it would at least load the top functions before any error is found. The worst part is that before I started messing around trying to add all this in, I had a very similar binding working from a repeating section. I'll be able to look at it more closely tonight.
1579440261
GiGs
Pro
Sheet Author
API Scripter
Something outside the code you posted is interfering, since that code does work on its own.
Thanks GiGs, At least now I know where i'm looking. If I figure it out i'll post the real issue!&nbsp;