Customizer Get Control Choices on Change

Because this is for a class, and you need to remove the old value and add the new value, you need to send that information to the preview.
I used a bunch of checkboxes, but it would be the same problem for radio inputs or a select. Knowing just the new value isn’t enough.

I wrote javascript for my control for the control pane that initialized the control with a field that contained all the possible values (sent as json in PHP). Then each time the user chooses, the value of the setting is updated to contain the off values, a separator, and the on values. Since I was doing this for classes also, I just used a comma.

Then in the preview script, the single value is split on the separator and the off ones are used with removeClass() and the on ones are used with addClass().

You can see the full code here: https://wordpress.org/themes/twenty8teen