What can I do to prevent constipation while traveling?

Manage your diet. Constipation is common while traveling. Drink lots of water and eat fresh fruits and vegetables when you can. Bring a mild laxative such as milk of magnesia (magnesium hydroxide) pills 'just in case' you get bound up. The most important thing is to drink lots of water.
Agree with diet. Constipation, in the vast majority of cases, has one of several nutritional causes: either you're not drinking enough water, you're not eating enough fiber, or you're eating too much of something constipating (low fiber junk food etc.). If you can figure out which one is the problem, you can cure the constipation.