snapsvg

2013-04-29

Monsieur, with these simple one-job jQuery plugins you are really spoiling us.

Today's new jQuery plugin is the check-all plugin: https://github.com/propcom/jquery-checkall

It has a couple of bugs at the time of writing, but I'll probably have those fixed this week.

Usage is quite simple (obviously); you target the 'All' checkbox and tell the plugin how to recognise all the others:

    $('#check-all').checkAll({
        rel: '.normal-checkbox'
    });

As with all of my plugins, if the selector selects multiple things, it loops over them so each one gets its own context.

2013-04-17

Announcing two new jQuery plugins

I like to keep things simple. I get a bit tired of trawling through pages of misinformation trying to figure out how to use a behemoth library when all I want is a simple feature.

Yesterday I uploaded very alpha (but working for me) editions of two new jQuery plugins that I wrote to solve the problem of having to read too much.

sort-by


http://github.com/propcom/jquery-sortBy

jQuery doesn't provide a .sort() method, but if it did it would be wrong.

sort-by uses the Schwartzian Transform concept to sort the children of the element you run it on. It takes a function, and the function is provided each child. The function returns a value by which the child may be sorted, and then the children are sorted in-place based on that.

You can view an example at http://propcom.github.io/jquery-sortBy

Checkbox Linked Lists


https://github.com/propcom/jQuery-checkbox-linked-list

This plugin relies on sort-by and jQuery UI. jQuery UI sucks so I'd like to not use it but for now it does.

The plugin takes all children of an element and splits them into two lists; the first list contains all children that contained a checkbox that was checked, and the second contains all children that contained a checkbox that wasn't checked. Then the checkboxes are hidden and the items can be swapped between the two lists. The plugin changes the checkboxes as it runs so that posting the form works exactly as it did before you implemented it.

Examples to come! Enjoy!