Quick fix for gallery onclick event attachment on non existent element