Reputation: 75
I'm trying to use jQuery Mobile for a mobile website (after trying and ditching jQTouch) and I think this is going to work beautifully. However, I've run into a formatting issue when hyperlinking to a second page.
I have a main index.php page which contains all of the static information I'm wanting to display. I'll have two links that will make SQL calls into a database for the information -- for these, I'm taking the code out of the index.php and calling a separate page: ucd.php. This second page load a dynamic listing that drills down into the database until they select the car they're looking for. My problem is when you're linked from the index page to ucd.php, the CSS formatting of the page is gone. If I load ucd.php on it's own, it formats properly. If I go index->ucd.php->list selection, index is formatted, ucd.php is NOT formatted, 1st dynamic list option IS formatted.
One thing I did notice is, when ucd.php is called, it changes the URL in the address bar to "http://localhost/#ucd.php" -- not "http://localhost/ucd.php". From what I've read on the jQuery Mobile site, it does this to keep the history properly in the hash. Should that cause any formatting problems?
(for space reasons, all pages start w/ and have the proper script loadings done. jQuery Touch 1.0a2, jQuery 1.4.4)
index.php:
<div id="mainpage" data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<h1>Car Dealership</h1>
</div><!-- header -->
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a">
<li><a href="ncd.php" data-transition="slide">Search New Cars</a></li>
<li><a href="ucd.php" data-transition="slide">Search Used Cars</a></li>
<li><a href="#service" data-transition="slide">Service/Parts Info</a></li>
<li><a href="#location" data-transition="slide">Find Us</a></li>
<li><a href="tel:8888675309" data-transition="slide">Call Us @ 888-867-5309</a></li>
<li><a href="#hours" data-transition="slide">Hours of Operation</a></li>
</ul>
</div><!-- content -->
<div data-role="footer" data-theme="a">
<h4>Thanks for visiting us!</h4>
</div><!-- footer -->
</div>
I'm only pasting the outputted HTML code from the .php page
ucd.php:
<div id="ucdmain" data-role="page" data-theme="a">
<div data-role="header" data-theme="a">
<h1>Used Cars</h1>
</div><!-- header -->
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="a" data-dividertheme="a">
<li><a href="ucd.php?ucd=make&make=Chevrolet" data-transition="slide">Chevrolet</a></li>
<li><a href="ucd.php?ucd=make&make=Chrysler" data-transition="slide">Chrysler</a></li>
<li><a href="ucd.php?ucd=make&make=Dodge" data-transition="slide">Dodge</a></li>
<li><a href="ucd.php?ucd=make&make=Ford" data-transition="slide">Ford</a></li>
<li><a href="ucd.php?ucd=make&make=GMC" data-transition="slide">GMC</a></li>
<li><a href="ucd.php?ucd=make&make=Honda" data-transition="slide">Honda</a></li>
<li><a href="ucd.php?ucd=make&make=Hyundai" data-transition="slide">Hyundai</a></li>
<li><a href="ucd.php?ucd=make&make=Infiniti" data-transition="slide">Infiniti</a></li>
<li><a href="ucd.php?ucd=make&make=Jeep" data-transition="slide">Jeep</a></li>
<li><a href="ucd.php?ucd=make&make=Lincoln" data-transition="slide">Lincoln</a></li>
<li><a href="ucd.php?ucd=make&make=Nissan" data-transition="slide">Nissan</a></li>
<li><a href="ucd.php?ucd=make&make=Toyota" data-transition="slide">Toyota</a></li>
<li><a href="ucd.php?ucd=make&make=Volkswagen" data-transition="slide">Volkswagen</a></li>
</ul>
</div><!-- content -->
<div data-role="footer" data-theme="a">
<h4>Thanks!</h4>
</div><!-- footer -->
Thanks in advance for any help, Josh Hogan
Upvotes: 1
Views: 2179
Reputation: 578
i was able to get a work around for this in alpha3 by doing the binding manually
first turn off the autoInitialize
$(document).bind("mobileinit", function () {
$.extend($.mobile, {
autoInitialize: false
});
});
and then after you have dynamically built the page, initialize jquery mobile manually
$(function () {
yourdynamicfunction();
$.mobile.initializePage();
});
Upvotes: 1
Reputation: 16915
Assuming you cefined <script>
tags well and you use JQM properly (looks like you do) this might be an issue I saw a few times with JQM alpha2 and jquery 1.4.4.
Try it with jquery 1.4.3 to see if it starts working.
Also - today JQM alpha3 was released and jquery 1.5 prerelease is out already. Try upgrading.
Upvotes: 0