externally calling a function within a local webview
I posted a similar question a few weeks ago, and it got buried in the forums unanswered. Here it is again hopefully clarified more:
I am trying to create a function within a local webview html that can be called from outside the webview.
I have code inside my webview's html saying:
function fu()
{
alert("hello!");
};
Ti.App.addEventListener("bar", function()
{
fu();
});
I can fire the alert from within the webview's html code by calling either:
fu();
or
Ti.App.fireEvent("bar");
Unfortunately I can't seem to trigger the alert from outside the html in the containing app.js.
I have tried calling both:
Ti.App.fireEvent("bar");
and
webview.evalJS("fu();");
from the app.js. Neither trigger the alert.
Any idea what I'm doing wrong?
Thanks much,
-Matt
1 Answer
-
create an onload event in the webview that will let the app.js know that is ready to receive events.
I had to set this to 500ms -1000ms to work properly.