jquery-check-all icon indicating copy to clipboard operation
jquery-check-all copied to clipboard

Trigger "change" event

Open AlexeyKosov opened this issue 8 years ago • 3 comments

Currently it doesn't trigger "change" event for children checkboxes so there's no way to perform an action after all the checkboxes are checked/unchecked.

AlexeyKosov avatar Feb 25 '16 14:02 AlexeyKosov

+1 for this. I need to count all checkboxes and selected checkboxes and report to user, Upon clicking checkbox, it does that but in wrond order.

durdenk avatar Aug 18 '16 01:08 durdenk

Simply update line 23 in

$children.prop('checked', $(this).prop('checked')).change();

(fire change on childrens)

adaniello avatar Sep 04 '16 15:09 adaniello

FYI this is what I've done 2 years ago.

  checkAll.prototype.init = function() {
    this._checkChildren();

    var plugin = this;

    this.$el.on('change', function(e) {
      var $children = $(plugin.options.childCheckboxes, plugin.options.container).not(plugin.$el);
      
      // 2015/9/5 modified by Thomas @ BeamStyle: Modification to only change checkboxes that need change, and then triggering the change event for those checkboxes
      var isChecked = $(this).prop('checked');
      $children = isChecked ? $children.not(':checked') : $children.filter(':checked');
      $children.prop('checked', $(this).prop('checked')).trigger("change");
    });

    $(this.options.container).on('change', plugin.options.childCheckboxes, function(e) {
      plugin._checkChildren();
    });
  };

bs-thomas avatar Feb 14 '17 16:02 bs-thomas