My first jQuery Plugin--SelectAll

03 Feb 2013

Refactoring code has been on my mind more lately than usual. I feel that if I'm not actively thinking and keeping in mind of what I'm coding, that I'm bound to rewrite code I've already written elsewhere. While working on Gavel's "Manage" page (still thinking of a clever title for that page), I realized that I had a set of checkboxes that I needed to keep track of for both my labels tab and my events tab. I wrote some small Javascript code to handle keeping track of labels as well as select/deselect all checkboxes, but when I started the events section, I realize that I didn't want to have to rewrite all this code. A lightbulb went off in my head and rather than googling for a jQuery plugin, I decided to challenge myself and write my own, so I present jQuery Select All. The plugin will take checkboxes as an input and keep track of them in an array. An optional select/deselect all can be passed in with the allSelector parameter. I'm sure this has been written already, but it was a good challenge for myself to think abstractly. Go check it out and fork me if you want!