Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

base tag resets after manually setting it (phonegap) #4916

Closed
knightcode opened this issue Aug 30, 2012 · 3 comments
Closed

base tag resets after manually setting it (phonegap) #4916

knightcode opened this issue Aug 30, 2012 · 3 comments

Comments

@knightcode
Copy link

I've got a jqm app running in phonegap. The main index.html, js, and css files are all stored locally. The index page consists of one jqm page (data-role=page), another div whose data-role is set to 'page' for rendering but is displayed as a stacked panel with a list of links, and several jqm dialog pages. When the app first starts up, the base of the document is set to a local file, e.g. file:///my/path/to/a/index.html, which is appropriate for loading all the local js and css files that are referenced from index.html with relative paths.

When the document is loaded, though, the base is set to the server to start loading new jqm pages with actual content. This works fine both using $.mobile.base.set() or manually finding and setting the href of the base tag.

This is when the stacked panel is shown. Almost every page from the server has a button to show the stack panel, and it is populated with a list of links to other jqm pages, all with relative paths to the server in their href's. As such, it's easiest if each jqm page has an href like, href="#stackedpanel" and a handler then catches the 'pagebeforechange' event, calls preventDefault(), and shows the stacked panel. So far so good.

When any of the links in the stacked panel are clicked, however, and not until they're clicked, the base tag reverts to the original file://my/path/to/a/index.html before the ajax call is made, which then fails. So, for instance, with a server, http://mysite.com/, and a relative path in the stacked panel of /foo/bar/, it tries to then load file:///foo/bar.

I can understand that this stack panel is originally in the local file context, but by manually setting the base, I've specified otherwise. Shouldn't it respect that?

@ghost ghost assigned johnbender Sep 18, 2012
@johnbender
Copy link
Contributor

@knightcode

It's hard for us to tack the base tag value and know when it's been changed. Though we could for instance say "It's different than what we have recorded from the page load, don't touch". I pushed a branch that's being saved for post 1.2 that supports the disabling of our base reset for folks who want to manage it manually. The setting is dynamic so if you want to disable it at some time after the initial load that would work.

<script src="http://jquerymobile.com/branches/basetag/js/"></script>

You can disable the base tag management and any time with $.mobile.dynamicBaseEnabled.

Let me know if that works for you and I'll close this issue in favor of #4456

@johnbender
Copy link
Contributor

@knightcode

Have you had a chance to try that branch?

@johnbender
Copy link
Contributor

No feedback. Closing for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants