@tojofo I made an attempt to do as you suggest here, but the code I ended up writing I think was uglier.  I think jquery is quite expressive actually.  I'm happy to be convinced against though.