Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Webviews and fireEvent

Is there anyway to return a value to the webview after a fireEvent has been called? I don't want to use evalJS…

This is a quick test tried (which obviously doesn't work but it gives you an idea):

In my webview:

function test(){

In my local js:

Titanium.App.addEventListener('test', function(e){
    Ti.API.info('Test local');
    return 'Test webview';

Is there a way to do anything like this? I know I can do something similar with evalJS, but it won't work quite the way I want it to….

— asked April 14th 2010 by JT Jankowiak
  • fireevent
  • return
  • webview

1 Answer

  • You need to setup a callback function, another event to fire back at the original file.

    Titanium.App.addEventListener('01', function(e){
       // do something
       Titanium.App.fireEvent('02', {return_value: 'return value'});
    Titanium.App.addEventListener('02', function(e){
       // do something with e.return_value;
    — answered January 13th 2012 by Dallas Clark
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.