Skip Navigation

[Suggestion] remember-plugin with Radio Button Support

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.

8
8 comments
8 comments