Page 1 of 1

Call custom Javascript from page.load

Posted: Sat Jul 19, 2014 9:16 pm
by Bad Addy

I have this simple code to start with, and I want to fire it on each page thats loaded, but it seems to not fire at all and I cannot understand why.

Here is the function:

precode
book = {};

book = {
"intro" : [{
"bookName" : "The Books Name"
}],

Code: Select all

 "page1": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }], 

 "page2": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }], 

 "page3": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }], 

 "page4": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }], 

 "page5": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }], 

 "page6": [{ 
     "text" : "This is the text that will be displayed on page 1 of the book.", 
     "images" : { 
         "image1" : 'localfile to image', 
         "image2" : 'localfile to image', 
         "image3" : 'localfile to image' 
     } 
 }] 

};

//console.log(book.page1[0].text);

function GetText(page) {

Code: Select all

 console.log(page); 

 var pText; 

 switch(page) { 

     case "p1" : 
         pText = book.page1[0].text; 
         break; 

     case "p2" : 
         pText = book.page2[0].text; 
         break; 

         } 

 console.log(pText); 

}
/code/pre

On the pages, I have this:

Image

The console.log above the function shows the text as it should, but any console.log in the function is not fired. I have tried:

precode
var GetText = function(page) {
/code/pre
precode
GetText = function(page) {
/code/pre

None seem to fire though, any reason this would not work in Appery ?


Call custom Javascript from page.load

Posted: Sat Jul 19, 2014 10:22 pm
by Illya Stepanov

Hello -

The custom code debugging is usually falls outside the scope of our support, we will need some time for our developer to look at this issue.


Call custom Javascript from page.load

Posted: Sun Jul 20, 2014 8:25 am
by Bad Addy

Its not the custom code thats wrong, it's the firing from the page to any function, does not matter whether its this code and any other.

Whats the correct way for Appery to fire a function which is in a custom file ?


Call custom Javascript from page.load

Posted: Sun Jul 20, 2014 9:05 am
by Illya Stepanov

Sorry, was my hasty assessment.

According to our documentation should work this way: http://devcenter.appery.io/documentat...


Call custom Javascript from page.load

Posted: Sun Jul 20, 2014 9:08 pm
by Bad Addy

Okay, it was because I was using the tablet and it was within the content frame. For some reason, when its in that frame, its unable to access any javascript function.

So it was Appery after all :)