Page 1 of 1

js in template not carried through to pages

Posted: Wed Jul 27, 2016 4:45 pm
by Terry Gilliver

I have altered the javascript of a template load event. This has been saved correctly, but the changes have not rippled through to the pages which are dependendent on that template.

Any ideas


js in template not carried through to pages

Posted: Wed Jul 27, 2016 5:33 pm
by Galyna Abramovych

Hello Terry,

Could you, please share the altered javascript with us?
Thank you!


js in template not carried through to pages

Posted: Thu Jul 28, 2016 12:58 pm
by Terry Gilliver

mainTemplate load event:

pre//this indicates how complete aprofile is:
//There are 20 profile items, so for every completed item
//we add 5%. This is than saved in the lititem counter value

var profileCompleteness = 0, key;

for (key in Apperyio.storage.trader.get()) {
//console.log("key = ", key);

if (Apperyio.storage.trader.get("$['" + key + "']") !== "") {
profileCompleteness += 5;
}
}

$("span.ui-li-count").text(profileCompleteness.toString() + "%");

/pre

This is the base template for most of my pages, I had a console.log in there in the for loop which I have commented out. It was beginning to get annoying as it kept filling my console every time a page was opened.

Sample script from one of the dependent pages:

pre//this indicates how complete aprofile is:
//There are 20 profile items, so for every completed item
//we add 5%. This is than saved in the lititem counter value

var profileCompleteness = 0, key;

for (key in Apperyio.storage.trader.get()) {
console.log("key = ", key);

if (Apperyio.storage.trader.get("$['" + key + "']") !== "") {
profileCompleteness += 5;
}
}

$("span.ui-li-count").text(profileCompleteness.toString() + "%");/pre

As you can see, it is the same code, but the console.log has not been commented out. This is the same for all the dependent pages. The idea of a template is change the template to change all its dependents.


js in template not carried through to pages

Posted: Mon Aug 15, 2016 12:22 pm
by Terry Gilliver

Any update on this?


js in template not carried through to pages

Posted: Tue Aug 16, 2016 4:57 pm
by Serhii Kulibaba

Hello Terry,

We are very sorry, but this is something outside the scope (https://docs.appery.io/docs/general-s...) of our standard support.

Could you clarify, what exactly doesn't work there?


js in template not carried through to pages

Posted: Thu Aug 18, 2016 10:01 am
by Terry Gilliver

The Problem is with the app builder itself.

If you make a change on a template then isn't it supposed to update the pages built from that template? If not what is the point of having templates?

I have made changes to the javascript template load event, but the changes are not seen in the dependent pages.


js in template not carried through to pages

Posted: Thu Aug 18, 2016 12:49 pm
by Illya Stepanov

Hello Terry -

Thank you for pointing out this issue -- I have reported this to our development team.

Because you are using on Load event in your template and the pages names are different on different pages it runs the actual on page load event on a specific page and takes your on load event from your template.
As a workaround you can delete the unneeded Load events on your pages.


js in template not carried through to pages

Posted: Thu Aug 18, 2016 5:00 pm
by Terry Gilliver

Thanks Illya