I'm trying to send some data from app.js to an open webview (external url, example: http://mysite.com/file.html), without success. I've check through many questions and answers and tried different solutions with Ti.App.fireEvent and Ti.App.addEventListener without any good success. I did however find a solution that did this with a local html-file some time ago, but weren't able to recreate this for an external.
app.js
Ti.App.fireEvent('helloWorld', { data : "Hello World" );
Ti.App.addEventListener('helloWorld', function(e)
{
// do something with e.data
});
doesn't seem to do anything.
Solved the problem by using evalJS app.js
web.addEventListener('load', function() {
var data = "some data";
web.evalJS("testJS('" + data + "')");
});
<script>
function testJS (data) {
alert(data);
}
</script>