Skip to content

A simple jQuery plugin to easily allow a single checkbox to control a group of checkboxes

Notifications You must be signed in to change notification settings

mjball/jQuery-CheckAll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

jQuery CheckAll Plugin

It's really simple.

Basic demo: http://jsfiddle.net/mattball/NBrg8/

Using the plugin

To use the checkbox with id master to control the checkboxes that are children of the form with id myForm, this is all you need:

$('#master').checkAll('#myForm input:checkbox');

To override any of the default settings, pass in an options object as the second argument. For instance, if I don't want to update the master checkbox when a slave is changed:

$('#master').checkAll('#myForm input:checkbox', {sync: false});

Options

All are optional (pun intended).

key           | default | description
---------------------------------------------------------------------------------------
sync          |  true   | boolean, keep the master sync'd with the slaves when a slave changes
onClick       |  null   | callback function, called whenever a slave checkbox is clicked
onMasterClick |  null   | callback function, called when the master checkbox is clicked
reportTo      |  null   | callback function, receives the number of slaves currently checked

Bonus awesomeness

Questions?

Please ask for help on Stack Overflow! I prefer to answer in a public manner in case other devs have the same question.

About

A simple jQuery plugin to easily allow a single checkbox to control a group of checkboxes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published