opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Full page-reload is triggered when hash is not present on initial page #102

Closed JohannesRudolph closed 11 years ago

JohannesRudolph commented 11 years ago

I load my root document at domain.com/app and have html5mode disabled. I noticed that when navigating to a subpage, i.e. /app/#!/subpage the default click handler registered by the adapter does not trigger a routing change but instead a full page refresh occurs.

If the app starts at domain.com/app/#!/ instead (so with an empty hash, but the hash is present), the adapter click handling does properly trigger a routing change.

I have isolated this issue to these lines:

rewrittenUrl = $location.$$rewriteAppUrl(absHref);

if (absHref && !iElement.attr('target') && rel !== 'external' && rewrittenUrl) {
    // triggers routing change here...

When the hash is not present in the root documents url, rewriteAppUrl will return undefined and a routing change thus not triggered.

Now, I feel that my app should behave identical whether I have an empty hash or no hash at all in my base url (only for the first page). So,

JohannesRudolph commented 11 years ago

The issue can be closed, it turned out my baseurl was not correctly initalized because my initial page could be either loaded from /app or /app/. I have implemented a redirect at the server to ensure that the correct base-url is always used.