Changed jQuery events to use delegated instead of direct events. Fixes #3.

Direct events to not update when the DOM changes. See
http://api.jquery.com/on/ for more info.