Hey guys and girls,
I'm looking for a bit of help with regards to converting my current website into a Mobile Safari Web App.
As you've probably guessed, I'm attempting to do this with xHTML, CSS & jQuery. I am currently following the guides from the O'Reilly book: http://building-iphone-apps.labs.oreilly.com/, but I'm having a bit of bother with the content in Chapter 3, using Ajax.
First things first, you can have a look at what I've currently got at: www.mkmdesign.co.uk/iphone
As you can see, I have a menu button in the top left that when pressed, displays the navigation links. Now, what I'm wanting to do (as the book explains) is for the content of these navigation links to appear within the current page, instead of opening up the html page. What the book is suggested doing is hijacking all the links and placing their content within the 'container' div on the current page when they are clicked/pressed. I have added the following code to my javascript file:
but as you will see if you click on any of the links, this doesn't work. When a link is clicked on, you are directed to the html file instead of it been placed within the current file.
Does anybody have any idea why this isn't working? It's starting to frustrate me a little bit!
Any help or advice would be much appreciated.
Also, on a different topic, ever since I've installed Snow Leopard, the iPhone Simulator in the SDK doesn't work. It just opens up and says the simulator application quit. I even uninstalled the SDK and downloaded it again, but it still doesn't work. Any ideas why?
I'm looking for a bit of help with regards to converting my current website into a Mobile Safari Web App.
As you've probably guessed, I'm attempting to do this with xHTML, CSS & jQuery. I am currently following the guides from the O'Reilly book: http://building-iphone-apps.labs.oreilly.com/, but I'm having a bit of bother with the content in Chapter 3, using Ajax.
First things first, you can have a look at what I've currently got at: www.mkmdesign.co.uk/iphone
As you can see, I have a menu button in the top left that when pressed, displays the navigation links. Now, what I'm wanting to do (as the book explains) is for the content of these navigation links to appear within the current page, instead of opening up the html page. What the book is suggested doing is hijacking all the links and placing their content within the 'container' div on the current page when they are clicked/pressed. I have added the following code to my javascript file:
Code:
//Hijacking Links
$(document).ready(function() {
loadPage(); //This actions the loadPage function when the document is ready
});
function loadPage(url) {
$('body').append('<div id="progress">Loading...</div>'); //adds the progress icon when page is loading
if (url == undefined) {
$('#container').load('index2.html #MainContent', hijackLinks); //loads the MainContent from index2.html into the current container
}
else {
$('#container').load(url + '#MainContent', hijackLinks);
}
}
function hijackLinks() {
$('#container a').click(function(e) {
e.preventDefault();
loadPage(e.target.href);
});
$('#progress').remove(); //removes the progress icon when page is loaded
}
//END Hijacking links
but as you will see if you click on any of the links, this doesn't work. When a link is clicked on, you are directed to the html file instead of it been placed within the current file.
Does anybody have any idea why this isn't working? It's starting to frustrate me a little bit!
Any help or advice would be much appreciated.
Also, on a different topic, ever since I've installed Snow Leopard, the iPhone Simulator in the SDK doesn't work. It just opens up and says the simulator application quit. I even uninstalled the SDK and downloaded it again, but it still doesn't work. Any ideas why?