What's going on?
An empty bottle is never really, truly 'empty'. This is not optimism, it's a scientific fact. When a bottle isn't full of liquid, it's full of air. Emptying a bottle full of hot water leaves you with a bottle full of hot air.
Here's another scientific fact: air expands when it gets hot and shrinks when it cools down. This phenomenon is called thermal expansion and it's what causes warm air to rise and cool air to descend. Because its volume increases, the density of air decreases as it gets warmer and being less dense is what causes it to float on cooler, denser air.
When air is trapped inside a rigid and airtight vessel, however, its volume cannot increase. Heat an airtight vessel and instead of expanding, the air pressure inside goes up. Cool an airtight vessel and the pressure goes down.
Seal a hot bottle with a solid rubber stopper and no more air can enter so the pressure inside drops as the air cools down, producing what physicists call a partial vacuum. The pressure inside the bottle will remain lower than the air pressure outside until you remove the solid stopper, allowing air to rush in until the pressures are equal.
The straw provides a more entertaining way for the pressure inside and outside the bottle to equalise. As the warm air inside cools down, the falling pressure is immediately equalised by the water rising into the straw. The higher pressure outside the bottle forces the water up, which reduces the volume of air inside, which equalises the pressure. But the fountain really gets going when the cold water touches the glass. That's because it cools the bottle down a bit faster, which causes the air pressure inside to fall a bit faster, which in turn causes even more cold water to flow in even faster.
When the air temperature inside the bottle has cooled down sufficiently, the pressure inside stops falling and the fountain stops working.