Last active
August 4, 2016 00:56
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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