problems firing an event listened for in a webview
I have a function in a local webview that I am trying to call from an outside Javascript.
I have added the function:
Titanium.App.addEventListener("drawLines", function()
{
myDrawFunction();
});
When I call the function from within the webview's html using:
Titanium.App.fireEvent("drawLines");
The function gets called, however if I put the same firing line in the .js file that defines the webview, the function is not called.
Any idea what I'm doing wrong?
Thanks.
-Matt
7 Answers
-
I think the webview inner js has a different context from the js file defining the webview.
the only thing they have in common is titanium.app.fireevent and addeventlistener -
Any idea how I can get a command in?
I've tried using the evalJS function to do both:
webview.evalJS("myDrawFunction();");
webview.evalJS("Titanium.App.fireEvent("drawLines");");neither seem to trigger the function.
-
I'm not sure I understand what you want to do.
-
I am trying to use the following vector graphics library:
http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm#browserIt works great within a local url webview, but I couldn't get it working outside of the webview.
I am trying to create a blank webview "canvas" window with externally accessible functions so I can draw lines into it from the app.js that contains the webview.
-
I have very similar problem.
in app.js I have added an event listener , and in a web view one of the linked js files have Ti.App.fireEvent .
with ver 1.0 it worked fine , since 1.2 the event is not captured and I do not see it runing .. -
As far as I'm aware / tested, Ti.App is not available in external URL's.
-
I'm experiencing a problem where I can open a webview, trigger an event, navigate to another local file (hosted on the iPad, except it's loaded via the <a href> instead of Ti changing the current page) but I can no longer trigger an event - it's as if the Ti context is no longer available.
How does one get around that, how do I make the context available for the second/third/etc pages which are accessed locally through the webview?