Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Check box manager: critique my jQuery plugin

 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I needed a way to take a set of check boxes and associate them with another check box that would act as a "check all" for them. My goals were:

1. Checking the "check all" check box will check all the managed check boxes
2. Unchecking the "check all" check box will uncheck all the managed check boxes
3. The "check all" check box will checked, unchecked, or indeterminate depending if all, none, or some of the managed checkboxes are checked.
4. An optional callback function can be provided, which will be called when the "check all" or a managed check box is checked or unchecked, but after all the states are updated. It will be passed the set of all checked managed check boxes.

So, I looked through the existing plugins, but I didn't look too hard, because I wanted an excuse to do it myself. Here's what I've got:



Here's some code where I test it:




On the positive side, it does work. However, I'm still an advanced beginner with jQuery and I'm terrible at JavaScript, so I'm probably making all sorts of dangerous mistakes and other bad choices. I could really use your expert opinions!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic