A model of edge localized modes (ELMs) in tokamaks is presented. The model of the L-H transition, which is based on electric field bifurcation, is extended to include the temporal evolution and the spatial structure. The existence of an electric field bifurcation implies that there is a hysteresis curve between the plasma gradient (thermodynamic force) and the associated flow of particles and heat. A time dependent Ginzburg-Landau equation is formulated for the electric field development, which leads to a limit cycle solution due to the hysteresis. A self-generated oscillation of the edge density appears, associated with periodic bursts of loss, under the condition of constant particle flux from the core. This is attributed to the small and frequent ELMy activity in H modes. Periodic decay and re-establishment of a transport barrier occur. This oscillation appears near the L-H transition boundary. It is found that in H and ELMy H states the edge region has a diffusion coefficient whose radial structure is intermediate (a mesophase) between the H phase and the L phase. This is attributed to the transport barrier. Its radial structure is governed by ion shear viscosity. The diffusion Prandtl number, the ratio of the viscosity to the diffusion coefficient, is found to determine the thickness of the barrier. The phase diagram of the L, ELMy H, H and L-H bistable states is obtained in plasma parameter space. In order to consider other types of ELMs, transient responses to the perturbations of the flux from the core are studied in each phase, In low collisionality plasmas a sudden decrease of the flux can cause the transient bursting of a few ELMs before the L-H transition is completed. A large scale pulse from the core causes a transient return to the L phase and a giant burst occurs in a high collisionality plasma. In the ELMy H state, external oscillations cause mode locking and other complicated dynamical effects (such as period doubling, trebling and intermittent bursts). The perturbation in the flux widens the parameter regime for which bursting occurs.