Fixed an AJAX related bug

I wasn't attaching the event handlers to the elements loaded via ajax.
Now I just use $(document).on instead.