Fix compatibility with jQuery 1.9

Fixes #46 and #59