Last active
February 4, 2017 10:55
-
-
Save ronisaha/8e25e2175f710e7fa49d3af8f55e1e99 to your computer and use it in GitHub Desktop.
Check Box Select All
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
| $("body").delegate('input[data-group]','click',function () { | |
| var name = $(this).data('group'); | |
| $(this).closest('.group_checkbox').find('input[name=' + name +']').attr('checked', this.checked); | |
| }); | |
| $("body").delegate('input[type=checkbox]:not([data-group])','change',function () { | |
| var name = $(this).attr("name"); | |
| var groupEl=$(this).closest('.group_checkbox'); | |
| if(!$(this).prop('checked')){ //unchecked so all selector need to be false | |
| groupEl.find('input[data-group]').attr('checked',false); | |
| }else{ | |
| groupEl.find('input[data-group]').attr('checked',(groupEl.find('input:checked[name=' + name + ']').length==groupEl.find('input[name=' + name + ']').length)) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment