Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue with click behaviour when ajaxEnabled == false #1174

Closed
blakehaswell opened this Issue · 6 comments

5 participants

@blakehaswell

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="http://www.domian.com">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)
    removeActiveLinkClass(true);

    //deliberately redirect, in case click was triggered
    if( hasTarget ){
        window.open( href );
    }
    else if( hasAjaxDisabled ){
      return;
    }
    else{
        location.href = href;
    }
}
@cryxia

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

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

@jblas jblas was assigned
@toddparker

@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

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

@cryxia

Great! Thanks for getting back to us.

@jblas jblas closed this
@toddparker

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
Something went wrong with that request. Please try again.