After DAYS of trying to get this to work and no luck I've thought I'll try get some help.
What I'm trying to do:
Phonegap + jQuery Mobile app (Done)
On selected pages pull html data from my wordpress website using the json API plugin.
Steps I want include: Opens app, user navigates to a page, once the page is shown if the device is online start to pull data and show it, if its offline alert the user with a message and have a refresh button to try again (maybe the users 3G dropped out for example).
What i've done
Successfully set up phonegap, jQuery mobile and multiple pages on the index.html page.
Successfully called document.addEventListener("deviceready", onDeviceReady, false); etc.
At the moment have the particular page getting data from my server BUT there is a issue of going back to the page it will do it again so its shown twice, then 3 times, then 4 times etc.
Transition flickers when loading the page and leaving the page that contains the json, I am using "$(document).on("pageshow", "#pagenamehere", function( event ) {" because I only want the json script to start when the page actually loads.
The data loads, but if I leave the page and come back the script activates again, so the data is doubled up, then if I come back triples. So I need a way for it to clear when I leave the page and it reloads when I go back to the page.
I am trying to set this up as a template page because I need to repeat it over a number of pages that points to a different post on my site.
I am creating a native iPhone app with jQuery Mobile and PhoneGap, most of the pages are static and will rarely be updated. When they are will be done so in an app update.
However some pages need to pull remote data from my website which uses wordpress. This data is a simple table of price comparisons of products (for now).
Current setup:
App connects to a particular page using JSON.
Pulls HTML content (which is a table) from a custom_field called 'NativeContent'.
Displays in the app (works quite well).
My concerns:
Future site structure changes (e.g. If i change the way I manage my content (maybe move from HTML tables to a mySQL/php query).
If I add elements that are not compatible with the jQuery Mobile version built into the app.
If I add jQuery Mobile features in the remote data (such as pop-ups etc) but someone hasn't updated the app it might not render properly (in future there may be something that requires jQuery Mobile 2.0 for example but someone has an old app with jQuery 1.1).
Ideas:
Can and will Apple approve an app where some pages have a web-view of a page with-in the page on the app? (Like Flipboard does with a story, Mashable etc etc). This way it could be a web-view of a /dev/page.php and I can make future changes on that page .... I can then maybe do localstorage and things like that?
Any other suggestions?
I can't get my head around a good way to do this ...
I have a really weird problem that started with jQuery Mobile 1.1
If i visit my website in Safari and I click a link on the home page (which consists of a list view for a menu) it works fine.
BUT If I view the website on my iPhone via web app (by clicking icon on the home screen) when I click a link it goes to the page ... loads it for a second flashes back to the home page ..... I can never get it to fully load any other page. But again works If I view it in Safari.
I have created a layout template for a app I plan to make native with PhoneGap and jQuery Mobile.
I NEED to pull page content from my website via JSON using this plugin and sorry I am a noob when it comes to Javascript and I have no idea how to do it :(. I admit I have been searching tutorials and can't get anything to work. Here is some code I have so far but it won't work ... maybe it's doomed to fail... Maybe I have to put something after this <script> code?
Anyone willing to help me out?
<script type="application/javascript">
$(document).ready(function() {
var url="http://myurlhere.com.au/api/get_page/?id=219&custom_fields=nativecontent";
Once I get it pulling content I can repeat this template file, change the page ID JSON is to pull to get different content ... I have all them menu's and everything set up already :) (I did this because I feel If i create the ENTIRE page via content from JSON including menus, headers, page conent, footer etc etc Apple will reject it.
I am currently writing a app for a website I run using wordpress. I am able to add a JSON plugin to allow me to pull data off the server. http://wordpress.org/extend/plugins/json-api/
My site has 500+ POSTS but only about 30ish static pages. The static pages are most important here's a example:
Home
Products > Products
Products > Product A
Products > Product A > Cheapest
I am in the process of creating menu's and a standard page layout design for the app (using jQuery Mobile).
Question
Is my only option to create the same URL structure in my native app and on each page have a different JSON link to call data? Or can I SOMEHOW create a dynamic page? Remembering I can't use .php on the iPhone (right?).
Therefore create a index.html page ... Then a /products/index.html page ... Then a /products/producta/cheapest.html page? - Each with a different JSON call on each page ...
For POSTS I want to create a page that lists all the posts .... Then I want to somehow create a dynamic page which will allow me to pull data from a post where the ID = post ID. For example somehow create ?id=x or something at the end of the page url in the native app so It knows what post to pull off the server ....