Open AlexeyKosov opened 8 years ago
+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.
Simply update line 23 in
$children.prop('checked', $(this).prop('checked')).change();
(fire change on childrens)
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();
});
};
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.