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

getAttrs returning old value of a select field

1458741826

Edited 1458742403
James
Sheet Author
I have a select field inside a repeating section. I have a sheetworker set to activate on a change in that field. Inside that worker I call getAttrs for the value of that field, and it is currently returning the value from before I changed the field. Gist of files The sheetworker can be found by searching for: on("change:repeating_weapon:wcl" The html can be found by searching for: "attr_wcl" EDIT Field updates correctly after closing the options window (I copied the design from the DnD 5e sheet by roll20)  So it's not getAttrs that's the problem by the look of it.  Still, the field is visibly incorrect until the options window is closed. Also, it's only the first repeating field that is affected. (Note, there is a fake repeating weapon line for Unarmed Combat - this is separate and fixed). I have cleared the cache, there are no add-ons enabled.
1458742536
James
Sheet Author
It looks like putting a non-empty value for my blank option solved the issue. That fixes it for me, but if anyone can replicate it then there's a bug here somewhere.
1458750333
Phil B.
Forum Champion
Sheet Author
It sounds like you were dealing with a "blank" field. When a field has no value, or is set to no value it will return the "default" or may have other strange behavior. This is because of the way Firebase (the provider we use to handle all of the data inside of games) handles blank/no values. When you set a value to blank, Firebase just deletes the key for that value, which 99% of the time works as it should except for some cases, like this when it's just a little weird. We've discussed possible changes for this many times, but everything we've come up with ends up being far more complicated and not worth the effort the get rid of this tiny bit of weirdness, that most of the time has pretty simple work-arounds. (like using a space instead of an empty string to blank a field)
1458770417
James
Sheet Author
That explains some other odd behaviours I had when using getAttrs with empty fields.  Thanks for the information. Is there anywhere where this kind of note is made available? Along with things like the availability of the Pictos font, and the Underscore.js library, this kind of information makes building the spreadsheets so much easier.  I've only found these out by reverse engineering sheets or forum posts.