I find I'm worse if anything stresses me on my run - I'm usually okay up to 6 miles, but anything over that and I plan a route where I know there are toilets available (which reduces stress levels before I set out and whilst I'm running).
I eat only plain toast or porridge (with water, I don't like it with milk) before a run and let that settle for about two hours, and also have a protein shake. After that I drink water diluted with a little smoothie to bring the carb content up to about 5%. Annoyingly my OH never has any problems and can wolf down a big chunk of fruitcake and go straight out.
If I'm running after work, then I have an additional snack around 5 p.m.
I am worse if I am not properly hydrated and I find that upping the water I drink a couple of days before a long run helps too. Anything over 6 miles and I take a sports drink with me, although I usually water them down as a find them too strong flavour-wise.
On a run which is longer than an hour and a quarter (71/2 - 8 miles) then I take an immodium about two hours before the run (unless I'm doing laps which are close to home and I can make a detour if necessary, in which case I don't bother) and if I'm running over 10 miles, then I'll take another about an hour before.
As insurance, I check all race events to make sure there are toilets - if it's a half marathon and they are only at the start/finish line, then I won't enter! The two marathons I have done, I was absolutely fine with the couple of imodiums. You can take the melting ones with you which don't need water, but although they call them instants, they are only instants in that they melt instantly. They still take an hour to work!
The day before a long run I do avoid curries or anything with lots of pulses. If the long run is a race, when I get more stressed out, then I'll reduce the fibre for two to three days before. I'm not particularly fond of dairy, so I can't say whether this is an issue - some people find that it helps to avoid this.
I think the main trigger for me is stress - not necessarily the stress of being worrined about getting caught short whilst I'm out, but putting my body under the stress which occurs as a result of a tough training session. So for me, I do everything I can to aleviate stress and find planning is key; keep myself well dehydrated, watch what I eat the day(s) before, an in the few hours before; know my route and potential toilet stops; take immodium (or boots do a capsule which is cheaper and has the same ingredients) as insurance if necessary.
Unfortunately, there is no magic fix. Just trial and error to find out what lessens the instances, and ultimately find a routine which works best for you.
And remember, you are not alone. Happens to lots and lots of runners, just most suffer in silence!
Soooz