DannyD
DannyD

Reputation: 2881

jquery mobile adds the new url to the old url

I'm using a mvc structure to display my jquery mobile pages. However, in IE, if I navigate to a new url, it adds this to the old url with a hash. For example, if I am on the following page:

http://localhost:49866/Home/Index

and I go to a new page, the url turns into this:

http://localhost:49866/Home/Index#/Newpage

Is there a way I can stop this? Some of my javascript only runs when a new page is loaded but with jquery mobile I guess it's not recognizing that my second page is a new page (I'm using a 'ready load' event for my js to run.

Upvotes: 1

Views: 87

Answers (1)

Adam Marshall
Adam Marshall

Reputation: 3009

This is how it works. I don't think you can work around it. Details here:

http://view.jquerymobile.com/1.3.1/dist/demos/widgets/pages/

What I tend to do is create functions to change page, that call

$.mobile.changePage("#myPage");

and then above or underneath, all the other stuff I want to call to get that page ready.

There are also events such as

$(document).on("pageshow", "#myPage", function () {

});

that you can add code into. See here for other page load events: http://api.jquerymobile.com/category/events/

You cannot use document.ready with JQM. See: https://stackoverflow.com/a/7422348/1061602

Upvotes: 2

Related Questions