Issue with click behaviour when ajaxEnabled == false #1174

blakehaswell opened this Issue Mar 3, 2011 · 6 comments


None yet
5 participants

I have a major issue with click behaviour on a site I'm working on. In my navigation I have the following link:

<a href="">Home</a>

When you click on that link the current page is reloaded, even when you're not on the home page.

After some investigation I've found the problem is in the click handling in jQuery mobile and how the url variable is created. The following code is run to create the url variable:

url = path.clean( href )

Since the protocol and (same) domain are removed that means the url in my example above is actually changed to an empty string. My proposal is that when ajaxEnabled == false we redirect to the variable href instead of url. ie:

if( isExternal || hasAjaxDisabled || hasTarget || !$.mobile.ajaxEnabled ||
    // TODO: deprecated - remove at 1.0
    !$.mobile.ajaxLinksEnabled ){
    //remove active link class if external (then it won't be there if you come back)

    //deliberately redirect, in case click was triggered
    if( hasTarget ){ href );
    else if( hasAjaxDisabled ){
        location.href = href;

cryxia commented Mar 23, 2011

This is more than just a major issue. When the href domain does not match the base href, this stupid cleaning mechanism rewrites all urls to the base href domain. This is such incorrect behaviour that I fail to see why this url cleaning mechanism was introduced in the first place. No matter what we do to pretty things up, the underlying fundamental behaviour of webpages should never be changed.


scottjehl commented Sep 22, 2011

Long time since this was last discussed. Has this since been worked out? We no longer set location.href or, for one, so I'm not sure if the problem still exists in the live codebase.

@ghost ghost assigned jblas Sep 22, 2011


toddparker commented Sep 22, 2011

@blakehaswell and @cryxia - can you test with the latest code? We resolve all relative links against the URL used to load the current page, should be fixed.

cryxia commented Sep 22, 2011

It took a while for me to find the issue in my codebase but I have tested it and it seems to be all ok now.


jblas commented Sep 22, 2011


Great! Thanks for getting back to us.

@jblas jblas closed this Sep 22, 2011


toddparker commented Sep 22, 2011

Thanks for answering @cryxia! Closing, but we can re-open is something comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment