Hi Evgene,
Thanks for the quick reply. I haven't worked it out yet, but I get the idea.
I have created a generic service (get_cache_news) with the following custom implementation:
code
Appery.get_cache_news_js = Appery.createClass(null, {
Code: Select all
init : function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},
process : function(settings) {
settings.beforeSend(settings);
if (this.__requestOptions.echo) {
settings.success(this.__requestOptions.echo);
} else {
// load JSON data from local storage
var cdata = localStorage.getItem("json_response");
// pass the JSON to the service, for output mapping
settings.success(JSON.parse(cdata));
}
settings.complete('success');
}
});
/code
I then automatically created parameters using a sample response (copied from the original REST service test - assuming the REST and localstorage responses are the same). I then mapped the response values to their destination components.
This is the javascript script I am currently running on load:
code
if (navigator && navigator.network && navigator.network.connection && navigator.network.connection.type) {
//alert('navigator');
var networkState = navigator.network.connection.type;
Code: Select all
if (networkState !== Connection.NONE) {
//alert('online');
onOnline();
} else {
//alert('offline');
onOffline();
}
// When debug only (in desktop browser)
} else {
//alert('not navigator');
onOnline();
}
// On offline
function onOffline() {
get_cache_news_data.execute(); //this is my generic service
}
// On online
function onOnline() {
get_news_data.execute(); //this is my REST service
get_category_data.execute();
}
/code
However, this does not work. With this implementation, I am now unable to progress to the news page, or any other page in the app. Am I missing something?