Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

js in template not carried through to pages

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

Galyna Abramovych
Site Admin
Posts: 84
Joined: Tue Mar 22, 2016 6:03 pm

js in template not carried through to pages

Hello Terry,

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

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

js in template not carried through to pages

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.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

js in template not carried through to pages

Any update on this?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

js in template not carried through to pages

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?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

js in template not carried through to pages

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.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

js in template not carried through to pages

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.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

js in template not carried through to pages

Thanks Illya

Return to “Issues”