Created
September 29, 2011 17:43
-
-
Save neopunisher/1251383 to your computer and use it in GitHub Desktop.
list checkbox tree with indeterminate
This file contains 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
jQuery.fn.reverse=[].reverse;jQuery(".nc>input:checkbox").click(function(){$this=jQuery(this);$this.parent().find("ol").find("input:checkbox").attr("checked",$this.is(":checked"))}); | |
jQuery("input:checkbox").click(function(){jQuery(this);jQuery("li.nc>input:checkbox").reverse().each(function(b,d){var a=jQuery(d),c=a.parent().find("input.cu");a.attr("rel",b);a.prop("indeterminate",!1);c.length==c.filter(":checked").length?(console.log("all checked:"+b),a.attr("checked",!0)):c.length==c.filter(":not(:checked)").length?(console.log("all unchecked:"+b),a.attr("checked",!1)):(console.log("indeterminate:"+b),a.prop("indeterminate",!0))})}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment