Fixed jQuery scoping bug in click context