pre-existing base tag breaks relative links #5083

Closed
pillex opened this Issue Sep 25, 2012 · 1 comment

Comments

Projects
None yet
2 participants

pillex commented Sep 25, 2012

Issue description

jquery mobile is currently unusable for websites with a base tag in the header and relative links on the page. an existing base tag is not properly recognized when generating full links from relative links.

instead of base+relativeLink jQM loads currentURL+relative link

Steps to reproduce

(ZEND framework. url-rewrite is on)

base tag in header: base href="http://www.example.com/"

on a page with url http://www.example.com/list/cars/

is a relative link href="show_car/id/35/"

if i hover over the link, google chrome shows correctly: http://www.example.com/show_car/id/35/

Expected outcome

clicking the link should load:
http://www.example.com/show_car/id/35/

base + relative link

Actual outcome

clicking the link tries to load
http://www.example.com/list/cars/show_car/id/35/

currentURL+relative link
base tag is not recognized

jQuery Mobile and jQuery core version used

all versions of jQM 1.2.0

Devices/platforms/browsers tested

-google chrome on win 7
-native android browser on android 4.1
-safari on iOS 5.1.1

Other relevant information

to make it work, i have to change two lines in every new rc of 1.2.0

in: https://github.com/jquery/jquery-mobile/blob/1.2.0-rc.2/js/jquery.mobile.navigation.js

on line 1239 instead of
if ( !url || !path.isPath( url ) ) { url = base;}
just
url = base;

this fixes the not recognized existing base tag. now clicking links loads the correct pages.

but on the loaded page (into the dom), the image paths were invalid. to fix this i had to replace
on line 848

var newPath = path.get( fileUrl );
with
var newPath = path.get( $('head base').attr('href') );

johnbender was assigned Dec 21, 2012

johnbender closed this Apr 10, 2013

Contributor

johnbender commented Apr 10, 2013

@pillex

Based on your comments in #4456 I've closed this issue. $.mobile.dynamicBaseEnabled = false in a mobileinit binding will prevent JQM from altering your base tag.

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