JadeRavens made a post on Reddit about the remember-plugin not being able to ‘remember’ the radio buttons.

So, I made a modification of the remember-plugin that handles the radio button groups. Here is the demo generator for it.

Essentially, it takes the ‘group’ of the buttons (by using .querySelectorAll to select all inputs that have the same name of the radio button) then saving the state of each radio button.

Which means that in the group, only one is checked and the others are not checked.

Though I am having problems with the saving of the value of a variable since after the second reload of the page, it will point to the last value.

The steps to see the problem (if there is an update() in the oninput of the radio button) is:

  1. Click a radio button.
  2. Reload the page, the variable will point to the last value in the group.

If there is no update() on the oninput, it will take two reloads of the page to point to the last value in the group.

EDIT: Seems to have fixed it by removing the triggerEvent upon loading the state/value of the inputs. Though, I’m sure there is a good reason why the ‘triggerEvent’ are there.

    • VioneT@lemmy.worldOPM
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      I think the problem happens when the radio button has a oninput or onchange handlers in which the triggerEvent triggers. See this fork of the problem. If the radio button doesn’t have any oninput and onchange it seems to be ok.

      It saves the current checked radio button but the value is not the same due to the trigger.

      • perchance@lemmy.worldM
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Ohhh the value itself, rather than the visual display, gotcha. I think it is because (as it turns out…) only the “clicked” radio button in a group of radio buttons has its oninput and onchange fired, even though the state of one of the others (which was the previously selected one) does actually change (from true to false). You can see that in the console here: https://perchance.org/ghl3jlo1cc#edit

        So the solution I think is to only run the triggerEvents for the checked radio button. That seems to fix it. Let me know if you notice any problems with that. Thanks for your help with this!

          • perchance@lemmy.worldM
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            1 year ago

            No problem! Thanks again for your help. Also, weird place to mention this, but as of a couple of days ago perchance now has 5 layers of database backups, and then within 4 of those backups, they’re duplicated across at least 2 data-centers. So I perhaps went a bit overboard lol, but I only had 3 layers for several years and it was also bugging me that I only had daily/weekly/monthly backups - i.e. no real-time database replication. So now we have that too. Previously it was possible for people to lose a day of work if something went terribly wrong with the server, since backups happened at most once a day.

            And while I’m adding stuff that’s irrelevant to this thread: This goes without saying, but don’t feel even slightly pressured to keep the /hub up to date, or keep jams running every month, etc. - perchance is a weird website, and will always be a weird website, so we have full creative license to be weird in ways that help work-hobby balance. And that sometimes just means leaving the site for 6 months (or indefinitely) because you’ve got other stuff going on. Perchance will never go corpo in any sense, never be acquired, never put ads on generators (except if it is absolutely required and fully-opt-in - like with the AI plugins which need GPU servers), and in general never “sell out”. In exchange for this, the community needs to be okay with weird stuff like me, you and other prominent perchance community members just abruptly leaving for several months if we want to, for literally whatever reason we want to. Obviously I’ll always ensure the servers keep running smoothly and keep improving perchance when I feel like it, but there should be no expectation of weekly shiny new features, silicon valley startup-level UI polish, hyped marketing announcements, or anything like that. To the extent that anyone in the community is somehow expecting that, I’ll happily keep disappointing them in exchange for keeping perchance weird and independent, and you should too RE balancing all your amazing hub/plugins/question-answering/jams/etc stuff with other work/life stuff you have going on. This wall of text is another way of saying you’ve done a lot of work for this community lol. Thank you 🥹🙏

            • VioneT@lemmy.worldOPM
              link
              fedilink
              English
              arrow-up
              2
              ·
              1 year ago

              Thank you for the kind words! I just like solving problems and try to increase my knowledge of JS/HTML/CSS through Perchance which is why I try to answer the questions on the forums (reddit, discord, and here), essentially helping myself (to learn new things and answers to the problems) by helping others. I’m also just doing it during my free time and when I don’t have any important things to do, so no need to worry about me xD. Lastly, thank you for creating this website and keeping it open ♥.