No,
pageinit will not do what is requested here.
pageinit will run your code when each page is initialized, not every time it is shown.
Use a
pageshow event. This is what it's for. Put it in code loaded from
<head>. Or, you may prefer to use
pagebeforeshow, if you want your code run before the user actually sees the page. The purpose of each event is really quite self-explanatory.
- $(document).on("pageshow", ".ui-page", function(event) {
- var $page = $(this); // It's convenient to get a jQuery object for the page
- // Do something here
- });
Pretty impossible to diagnose your problem without seeing any code or HTML. I'm guessing you are facing other issues, but I can only guess.
----
- You're mixing JQM 1.2 CSS with JQM 1.3 Javascript. I wouldn't expect that to work well.
- You're loading jQuery UI. JQM isn't designed to work with jQuery UI. Some people have gotten some parts of jQuery UI to work with JQM. I don't recommend trying this, though, because it will almost certainly break every time there is a new release of JQM, and the two have drifted apart sufficiently that they are now almost impossible to use together.
- If the reason you are loading jQuery UI is because you're using jquery.ui.map, you don't need jQuery UI. jquery.ui.map is designed to work with either jQuery UI or JQuery Mobile.
- You have duplicate IDs (at least
logo) in different pages. This WILL NOT work. HTML does not allow more than one element with the same ID in a document. Browsers simply to not know WHICH of multiple elements with the same ID you mean to affect, and so they punt. They all punt in different ways.
I've mentioned this before. It seems to be the #1 mistake made by JQM newbies. They just don't want to take advice not to duplicate IDs, no matter how many times they are told. Use a class instead.
- You need to read and understand the parts of the documentation about how JQM loads pages in the document.