Make it work inside jQuery dialog