Your setCheckboxes() JS function implementation does not trigger onChange() event for checkboxes and I need this for my project.
I changed your function a little so now it's more jQuery'sh and triggers change event.

Here is updated function.

  function setCheckboxes(state) {
    $('input:checkbox', checkBoxes).each(function() { $(this).attr('checked', state).change(); });
  }

Comments

markus_petrux’s picture

How about this?

  function setCheckboxes(state) {
    $('input:checkbox', checkBoxes).each(function() { this.checked = state; $(this).change(); });
  }

...it needs a bit less resources to execute than using jQuery to alter the checkbox status, plus this is compatible with all browsers, AFAIK.

vgarvardt’s picture

This will work too.
If you want you can use mixed code style. As for me I don't think that setting attribute using jQuery API takes much time.

markus_petrux’s picture

Category: bug » feature
Status: Needs review » Fixed

Well, I ended up committing a slightly different version of this.

$('input:checkbox', checkBoxes).attr('checked', state).change();

There's no need to use the jQuery each() iterator, and it is now 100% jQuery-ish.

I have also added blur() effect to click events. I'll pack a new release with these changes that should be available as soon as the packaging system proceeds.

Also, I've changed to issue status to "Feature request" as this was not really a bug.

And then... I'm going to write a new version that will also work in tables, where more than one set of checkboxes exist. I'll leave than one in DEV stage for a while...

markus_petrux’s picture

Status: Fixed » Closed (fixed)