/*
*为列表绑定全选事件
*包裹表单需要有id,类名包含form-list
*input的class均为checkbox
*/
checkAll: function() {
$(document).on('click', '.form-list input.checkbox', function(event) {
var flag = true,
id = $(this).parents('form').attr('id'),
checkbox = $('#' + id + ' input.checkbox')
checkall = checkbox[0],
that = $(this)[0];
if (that == checkall) {
flag = that.checked;
checkbox.each(function(index, el) {
$(this)[0].checked = flag;
})
} else {
checkbox.each(function(index, el) {
if ($(this)[0] != checkall) flag = ($(this)[0].checked == false) ? false : flag;
})
checkall.checked = flag
}
});
}
网友评论