The colored bubble solution uses special dyes called leuco dyes. For instance, the purple bubble uses a chemical called crystal violet lactone. After the bubble pops, the colored splatter disappears with friction, water or exposure to air.
In a normal soap bubble, surfactants reduce the surface tension of the water and allow the bubble to form.  To create a colored bubble, dye molecules must bond to the surfactants. Each dye molecule in Zubbles is a structure known as a lactone ring. When the ring is closed, the molecule absorbs all visible light except for the color of the bubble. However, subjecting the lactone ring to air, water, or pressure causes the ring to open.  This changes the molecule's structure to a straight chain which absorbs no visible light.
Lactone rings can be produced whenever a long chain molecule contains acid functionality on one end, and alcohol functionality at the other. The two ends of the molecule react in a condensation reaction, ejecting a water molecule. To drive the reaction back towards the long chain, pressure, heat or an excess of water must be added.