I am trying to fire an event from an external HTML page open inside the Titanium website.
app.js file ...
var group, now, tab, view, window;
now = new Date();
view = Titanium.UI.createWebView({url: 'http://MYWEBSITE.com/index.htm?time=' + now.getTime()});
window = Titanium.UI.createWindow({tabBarHidden: true, navBarHidden: true});
window.add(view);
Titanium.App.addEventListener('browse', function(e) {
Ti.API.info("I received " + e.something + " from the webview.");
});
group = Titanium.UI.createTabGroup();
tab = Titanium.UI.createTab({title: 'window', window: window});
group.addTab(tab);
group.open(tab);
js excerpt from web page ...
$("#testButton").mousedown(function() {
alert ("I got clicked.");
Ti.App.fireEvent('browse', {something:'stuff'});
});
(I specify the time in the URL so that the page is always fresh.)
Adding an event listener, as shown above, or using view.addEventListener, compiles, but ultimately does not work.
Using Titanium.UI.WebView.addEventListener generates an error message that the object does not exist.
Do I need to open the URL / webview in another way?
Also, since Titanium.App.fireEvent is not a recognized function besides Titanium, how can I prevent a JavaScript error?
Thank.