Page 1 of 1

Global functionality

Posted: Thu Jan 14, 2016 2:49 pm
by TonyS

I'm want a function that checks the remote DB for changes and notifies the user when there are whatever page the are on. Currently the check is only made on the home page when the user opens the app. 2 things; do I have to repeat the function on every page and how do I trigger the check, a timer?

Thanks


Global functionality

Posted: Thu Jan 14, 2016 4:38 pm
by Serhii Kulibaba

Hello Tony,

Please try to use following JS code to create global service(this code you need to add to your new JS asset):

prevar onLoad = function(){
console.log("onloaded");
//Where "ToDoDB_dogs_list_service" is your service.
//and "yourGlobalServiceDataSourceName" will be your global service datasource.
window.yourGlobalServiceDataSourceName = new Apperyio.DataSource(ToDoDB_dogs_list_service, {
"onBeforeSend": function(jqXHR) {
},
"onComplete": function(jqXHR, textStatus) {
},
"onSuccess": function(data) {
},
"onError": function(jqXHR, textStatus, errorThrown) {}
});
};
jQuery(window).load(onLoad);/pre

Then you can invoke your global service with following JS code:

preyourGlobalServiceDataSourceName.execute();/pre


Global functionality

Posted: Thu Jan 14, 2016 4:55 pm
by TonyS

Thanks you:)


Global functionality

Posted: Thu Jan 14, 2016 11:16 pm
by Julian De La Rosa

Also if you use template in platform you can put the function there and will be inherited by all pages.