Skip to content

Instantly share code, notes, and snippets.

@tuanphpvn
Last active August 4, 2016 00:56
Show Gist options
  • Save tuanphpvn/97ccd098475264f4f512 to your computer and use it in GitHub Desktop.
Save tuanphpvn/97ccd098475264f4f512 to your computer and use it in GitHub Desktop.
Select all checkbox. What you need to add data-ride="ap-checkboxall" to the select all checkbox and point to his child. That zit #Widget
(function($) {
var $arr_checkall = $('[data-ride="ap-checkboxall"]');
/* bind checkall */
$arr_checkall.click(function() {
var $this = $(this),
_data = $this.data();
$(_data.child_selector).prop('checked', $(this).is(':checked'));
});
$arr_checkall.each(function(i, v) {
var $this = $(this),
_data = $arr_checkall.data(),
$childs = $(_data.child_selector);
$childs.on('click', function() {
var count = $(_data.child_selector + ':not(":checked")').size();
$this.prop('checked', !count);
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment