views:

26

answers:

1

Goal

When the user clicks an element (with class="menu"), the default action should not be executed. The user should be presented with a menu with options. When an option has been clicked, then the default action should be executed.

Problem

It's very problematic to stop the original click event in the first place, because it seems impossible to restore "default behavior" after that - is there a way to just delay the event until the user clicks a menu item?

Example

What i want to happen: Click a link. A menu is appended to the body. Click a menu option. The default behavior for the original click is now executed (which means triggering the click event of the originally clicked link and redirection to example.com).

jsFiddle

HTML, JS and CSS here: http://jsfiddle.net/arex1337/Tjwmx/

PS: If you want to know what I need the functionality for, here are some hastily and badly written thoughts about the application I have in mind: www. scribd.com /doc/39573220/MyJsApp

A: 

This is not possible; you'll need to simulate the default behavior in code.

You can set location.href to the link's href.

SLaks
1. Why isn't this possible? It's certainly possible to do SOME stuff before you let the original click event happen.2. Your solution doesn't trigger the native click event which may trigger other stuff.3. I would rather not try to simulate behavior and trigger all the proper events for each type of element. Link = native click + follow href. Text field = native click + focus. And on and on. To let the original event through is much better.
arex1337
@arex: 1: It just isn't. You can't cause the click handler to block without freezing the entire browser. 2. I realize that. You can raise the event using jQuery. 3. You'll need to write a lot of code.
SLaks