Temples are sacred places and there are certain rules to be followed before entering temple. These rules are known as Pancha Shuddhi (5 kinds of purity). According to this 5 types of shuddhi needed before going to temple:
- Sharira (bathe body)
- Ahara (Satvic food)
- Manas (mind)
- Vaak (Speech)
- Karma (deed)
There are two questions asked, first one 'Is it okay if I go temple after eating something?'
As per the second rule Ahara Shuddhi(purity of food items), only Satwik food items are allowed before visiting the temple. Even some of the food items like onion, coffee, tea, overly spicy food, salty food, etc are not Satwik.
If it is a long pilgrimage, there can be exceptions but you should be aware to choose the Satwik food items. Usually during the pilgrimage, we depend on hotels. Make sure that it is a vegetarian hotel otherwise they may have mixed up all food items.
There is one more aspect to the Satwik food. The purity of food items also depend on the people who cook. It depend on their purity of body, mind, speech and deed. If you are having homely food, then you can almost ensure this. But in most of the hotels, the case could be much worse. Even Satwik food become Tamasik or Rajaswik food depending on this aspect, but you never get a chance to realize this. Brahmins know this fact very well and hence they try to avoid outside food because of this reason.
So your grandparents are right and it is better to have no food as we can not ensure the purity of the food items even if those are vegetarian food items. See this question and answer for the details What are Tamasic, Rajasic and Sattvic foods?.
Also your question can be related to the question Why are non-Hindus not allowed inside temples?. Many of the temples have restrictions for non-hindus because of the above reasons.
The rule is applicable to all people (even if you are hindu) and hence the answer for your second question 'can I eat non-veg and visit a temple?' is definitely a NO.
I am not aware of any unplanned events in temples. Usually all events in temples are planned and if you had non-veg food, you should not go to temple. Actually it will be an insult to other people who follow these rules. Temple also will need to have it's standard procedures to clean the atmosphere if there is any kind of impurity. It is known as 'Shuddhi Kalasam' in Kerala. See this link. The responsibility and it's deed is upon you for sure.