sdenec / tidy-ui_game-settings

formerly FVTT UII Game Settings
16 stars 6 forks source link

Clicking on a checkbox's label does not fire jQuery change events for that checkbox #66

Closed cs96and closed 2 years ago

cs96and commented 2 years ago

I have some jQuery change() events configured for some of the checkboxes in my module's settings (damage-log). TidyUI allows you to click on the label, as well as the actual checkbox to toggle the state. However, if I click on the label, then the change events aren't fired.

From the jQuery docs for change()...

Note: Changing the value of an input element using JavaScript, using .val() for example, won't fire the event.

However, you can get the change events to fire if you use .click().

I.e changing this...

  html.find('.form-group label span').on('click', function(){
    var checkbox = $(this).parent().parent().find('input[type="checkbox"]');
    checkbox.prop("checked", !checkbox.prop("checked"));
  });

to this...

  html.find('.form-group label span').on('click', function(){
    var checkbox = $(this).parent().parent().find('input[type="checkbox"]');
    checkbox.click();
  });

...will cause my events to fire. Would it be possible to get this changed please?

sdenec commented 2 years ago

Sure thing!