tuan
8/21/2015 - 8:44 AM

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

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);