About Onion
Always provide reference for the context. Can you answer following question? Let assume you have an interview, will you go to that interview dirty and smell coming out of your body or mouth?
To my understanding prayer in the mosque is discouraged to not inconvenience people around you, but at home praying after eating onion it is ok. Normally it takes several hours to get rid of bad breath of onion, garlic or radish. Even at home we should try mouth wash before prayer. This comes under general principal in Islam not to inconvenient other. It is not just limited to onion, anything that would cause odor (onion, garlic, Radish, etc.) should be avoided in the mosque, whether it is breath, body odor, foot odor or smelly clothes.