jquery/jquery-mobile — Issue #3405: preventDefault doesn't work on anchor tags unless rel=external
Author: renaissanceGeek
Created: 2012-01-10 19:03:13+00:00
State: open

This is related to issue 729 (https://github.com/jquery/jquery-mobile/issues/729) which was closed with the comment that the user should disable ajax handling if they wanted to prevent the default form submission, but I wanted to point out that the same problem occurs with calling preventDefault in the click event of any link as well.

Consider the following very simplified example:

What happens is that we get the alert, but the preventDefault() doesn't work, so we continue to the link's href. This is because of jqm's async page loading model, so if we put rel=external on all the links, we can stop it from happening, but that also removes one of the main benefits of using jqm in the first place.