Call non page scoped js function from another page
I have a page (main) that contains a js function that is declared outside of the dojo.declare and hence is not page scoped.
Is it possible to call this function from another page (page2)?
I have tried main.functionName and this.functionName but neither of them work.



Calling js func from another page
Presuming the main page is loaded in the app (not destroyed), the function is in the top level. From the page2 page code you can just call
myFunc();If the function was defined as a page function, that works too, just use the page name, e.g. 'main.myFunc();' or if in another page in a page container, 'main.pageContainer1.page.myFunc();'
-Ed
Edward Callahan
Senior MTS
WaveMaker/SpringSource/VMware
===========================
WM 6.4.5, 6.5.M1
If you have function
If you have
function myfunc() {alert("You have found my fun");}dojo.declare("Page5", wm.Page, {
....
});
myfunc() can be called any time just using
myfunc();The one rule is that Page5 has to have been loaded. It can be unloaded and myfunc will still exist. But if Page5 hasn't loaded (not your main page, not in any page container, or its in a page container but the deferLoad property kept it from loading) then myfunc won't yet have loaded.
Michael Kantor
SMTS; WaveMaker/SpringSource/VMware