fixes priority order and click javascript events