The on/off mechanism of this “fountain” is effected through the pressure of the air space in the bottle, Pair.
When the bottle is not sealed
As the water drains through the holes, air from outside enters to “top up” the air space so Pair is always Patm. Since Pair + hρg > Patm, water squirts out continuously.
When the bottle is sealed
As the water drains, the air space expands and without any “top up” of the air molecules, Pair must drop. When Pair is low enough such that Pair + hρg = Patm, water stops squirting.
By how much must the air space expand? Well Patm, is about 760 mmHg, or about 1000 cmH20. If Boyle’s Law is roughly valid, then the air space only needs to expand by 1% for Pair to decrease by 1%. This to enough to make Pair 10 cmH2O below Patm, enough to “suck” and hold a water column of 10 cm in the bottle.
P.S. Actually, the required expansion is even less because surface tension also helps to keep the water in the bottle.